Deep-temporal-clustering icon indicating copy to clipboard operation
Deep-temporal-clustering copied to clipboard

Whether the centroids have been updated?

Open pancratm opened this issue 2 years ago • 1 comments

When the code is run to cluster in train_ClusterNET() function and compute Q/P in forward(), the similarity computed based on self.centroids which are always stay the same. Will the centroids be updated? I'm also trying to add steps to update in training_function but the loss seems not to descend. Can you help me? Thanks.

    def forward(self, x):

        z, x_reconstr = self.tae(x)
        z_np = z.detach().cpu()

        similarity = compute_similarity(
            z, self.centroids, similarity=self.similarity
        )

        ## Q (batch_size , n_clusters)
        Q = torch.pow((1 + (similarity / self.alpha_)), -(self.alpha_ + 1) / 2)
        sum_columns_Q = torch.sum(Q, dim=1).view(-1, 1)
        Q = Q / sum_columns_Q

        ## P : ground truth distribution
        P = torch.pow(Q, 2) / torch.sum(Q, dim=0).view(1, -1)
        sum_columns_P = torch.sum(P, dim=1).view(-1, 1)
        P = P / sum_columns_P
        return z, x_reconstr, Q, P

pancratm avatar Oct 12 '22 02:10 pancratm

Excuse me, have you solved this problem?

hust-zzx avatar Nov 13 '23 08:11 hust-zzx