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 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.