zhmiao / OpenLongTailRecognition-OLTR

Pytorch implementation for "Large-Scale Long-Tailed Recognition in an Open World" (CVPR 2019 ORAL)
BSD 3-Clause "New" or "Revised" License
849 stars 128 forks source link

About visual memory M (centroids) update problem #3

Closed emma-sjwang closed 5 years ago

emma-sjwang commented 5 years ago

Thanks for the awesome work.

But I do not find the related codes to update the centroids. In line 45 of file run_networks.py :

if self.memory['init_centroids']:
    self.criterions['FeatureLoss'].centroids.data = self.centroids_cal(self.data['train_plain'])

these codes are utilized for centroids initialization.

In the paper, Section 3.1, Para Learning Visual Memory M, the centroids are updated in two steps. Could you kindly give me more hints about how to realize the second step, which is the propagation step by alternatively updating the direct feature and the centroids.

Thanks a lot.

zhmiao commented 5 years ago

Hello @EmmaW8 , basically after the first stage, where a plain base model is trained, we use the plain model to calculate the class centers. Then in the beginning of the second stage, we use these centers to initialize the self.criterions['FeatureLoss'].centroids.data, and from https://github.com/zhmiao/OpenLongTailRecognition-OLTR/blob/master/run_networks.py#L98 , we initialize an optimizer for the criterion. During training, in the self.batch_backward() function (https://github.com/zhmiao/OpenLongTailRecognition-OLTR/blob/master/run_networks.py#L139), the criterion optimizer is stepped, and this is where the centroids are updated according to the losses, because centroids are updateable parameters of the feature criterion in stage 2. Does this make sense to you?

emma-sjwang commented 5 years ago

@zhmiao Thank you for your detailed responce. :) It is clear to me now~