michaal94 / torch_DCEC

Pytorch Deep Clustering with Convolutional Autoencoders implementation
MIT License
98 stars 30 forks source link

About clustering center update #4

Closed RealNewNoob closed 4 years ago

RealNewNoob commented 4 years ago

I tried to print the clustering centers while training by the below code added to the Clusteringlayer, however, I noticed that the clustering centers never change in the training process. I also checked the gradient of the clustering centers, and to my surprise, they are not zero.

class ClusterLingLayer(nn.Module): ......... def return_weight(self): return self.weight

for name, param in model.named_parameters(): if 'clustering.weight' in name: print('clustering weight data and grad:') print(param.data) print(param.grad)

I have no idea what is going on.

RealNewNoob commented 4 years ago

I believe the problem is solved in https://discuss.pytorch.org/t/gradient-exist-but-weights-not-updated/69270

michaal94 commented 4 years ago

Seems the solution was found