neuroailab / LocalAggregation-Pytorch

88 stars 17 forks source link

Why 'loss.backward()' is carried out before the k-means function? #7

Open MrYaoH opened 3 years ago

MrYaoH commented 3 years ago

In the ‘train_one_epoch‘ function,I notice that when 'loss.backward()' is carried out for the first time,the Ci is not clustered by k-means method. Clustering does not work until the second data batch in the first epoch enters. This problem make me confused. In other words,why 'loss.backward()' function is defined before the k-means function? In the paper, the k-means function should do before computing the loss. right?

chengxuz commented 3 years ago

Sorry, I am not super familiar with the pytorch implementation, but I think even if for the first batch, the k-means is not done, it can just use the initial value of the C_i or previous saved values to do the computations, this would just make the first batch not used super well, which should be totally fine.

MrYaoH commented 3 years ago

Sorry, I am not super familiar with the pytorch implementation, but I think even if for the first batch, the k-means is not done, it can just use the initial value of the C_i or previous saved values to do the computations, this would just make the first batch not used super well, which should be totally fine.

Thank you for your reply. I sincerely appreciate your work.