Hi~ I'm now using the implementation from , and the center was initilized as self.centers = nn.Parameter(torch.randn(self.num_classes, self.feat_dim)). I'm confused why this kind of initialization guarantee the final center is the center of the given features/embeddings in a certain class?
I tried this center loss as above but confused why it works in theory?
11 Answer
Because the random initialization doesn't change the end result. It gives a direction for the backpropagation that the embeddings will get closer the to the centers and it doesn't matter which location of the centers that you chooose. It'll achieve the purpose ultimately.
This happens in the training phase.
In the testing phase, the feature extraction model that you trained is used and the center location information is not used at all.