alpha = config['alpha'] | alpha = config['alpha'] | ||||
beta = config['beta'] | beta = config['beta'] | ||||
d = config['d'] | 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))) | # 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 = torch.mul(a, torch.mul(torch.sub(1, a), torch.sub(1, torch.mul(2, a)))) | ||||
# b = 1 * a * (1 - a) * (1 - 2 * a) | # b = 1 * a * (1 - a) * (1 - 2 * a) |
kmeans_model = KMeans(n_clusters=config['cluster_k'], init="k-means++").fit(user_embeddings) | 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() | 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']) | # indexes = data_batching(indexes, C_distribs, batch_size, training_set_size, config['cluster_k']) | ||||
# random.shuffle(indexes) | # random.shuffle(indexes) | ||||
C_distribs = [] | C_distribs = [] |