pytorch-adacos
pytorch-adacos copied to clipboard
No optimizer for metric_fc?
As far as I know, the centers (self.W
) in losses should be updated during training.
To do that, it requires using optimizers on both the model and the metric_fc
(e.g. ArcFace).
However, I did not find any optimizer set on metric_fc
in your code so technically the centers won't be updated anyway...
Is it supposed to be like that?
Very good catch :) Then only backbone is learned and in classification layer just random weight stay for all training. Author should change this implementation, guided by your explenation.
what you can do is inside your model class define let's say you are using ArcFace. define it as follows
class Model:
def __init__(self , args):
#Define your model here
self.fc = ArcFace(num_features , n_classes)
def forward(self , inp , targets):
feature = self.model(inp)
arc_op = self.fc(feature , targets)
return arc_op
when you define optimizer opt = SGD(model.parameters() , 1e-3)
I think this should work, since the ArcFace Repo you mentioned gets only features(in that repo 512 dimensional embedding) from the Resnet Model and the passes it to ArcFace module. Hence I think defining model as above should in theory work.