| @@ -8,7 +8,7 @@ def cl_loss(c): | |||
| alpha = config['alpha'] | |||
| beta = config['beta'] | |||
| d = config['d'] | |||
| a = torch.div(1, torch.add(1, torch.exp(torch.mul(-1, torch.mul(alpha, torch.sub(torch.mul(d, c), beta)))))) | |||
| a = torch.div(1, torch.add(1, torch.exp(torch.mul(-1, torch.mul(alpha, torch.sub(torch.mul(d, c.squeeze()), beta)))))) | |||
| # a = 1 / (1 + torch.exp((-1) * alpha * (d * c - beta))) | |||
| b = torch.mul(a, torch.mul(torch.sub(1, a), torch.sub(1, torch.mul(2, a)))) | |||
| # b = 1 * a * (1 - a) * (1 - 2 * a) | |||
| @@ -260,7 +260,7 @@ if __name__ == '__main__': | |||
| kmeans_model = KMeans(n_clusters=config['cluster_k'], init="k-means++").fit(user_embeddings) | |||
| tr.cluster_module.array.data = torch.Tensor(kmeans_model.cluster_centers_).cuda() | |||
| if iteration > (0): | |||
| if iteration > 0: | |||
| # indexes = data_batching(indexes, C_distribs, batch_size, training_set_size, config['cluster_k']) | |||
| # random.shuffle(indexes) | |||
| C_distribs = [] | |||