Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
goodman1204 committed Mar 18, 2021
1 parent fe18ba7 commit d2c716a
Show file tree
Hide file tree
Showing 47 changed files with 103,086 additions and 16 deletions.
10 changes: 8 additions & 2 deletions can.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def training(args):
mean_precision=[]
mean_recall = []
mean_entropy = []
mean_time= []


# adj_norm = drop_edge(adj_norm,Y)
Expand Down Expand Up @@ -152,6 +153,7 @@ def training(args):
loss_list=None
pretrain_flag = False

start_time = time.time()
for epoch in range(args.epochs):
t = time.time()

Expand Down Expand Up @@ -199,6 +201,8 @@ def training(args):
"time=", "{:.5f}".format(time.time() - t))

print("Optimization Finished!")
end_time = time.time()
print("total time spend:", end_time- start_time)

pre, mu_c=clustering_latent_space(z.cpu().detach().numpy(),tru)
plot_tsne(args.dataset,args.model,epoch,z.cpu(),torch.tensor(mu_c),Y,pre)
Expand Down Expand Up @@ -226,6 +230,7 @@ def training(args):
mean_precision.append(round(precision,4))
mean_recall.append(round(recall,4))
mean_entropy.append(round(entropy,4))
mean_time.append(round(end_time-start_time,4))


# np.save(embedding_node_mean_result_file, mu_u.data.numpy())
Expand All @@ -240,7 +245,8 @@ def training(args):
# print('Test edge AP score: ' + str(ap_score))
# print('Test attr ROC score: ' + str(roc_score_a))
# print('Test attr AP score: ' + str(ap_score_a))
metrics_list=[mean_h,mean_c,mean_v,mean_ari,mean_ami,mean_nmi,mean_purity,mean_accuracy,mean_f1,mean_precision,mean_recall,mean_entropy]
# metrics_list=[mean_h,mean_c,mean_v,mean_ari,mean_ami,mean_nmi,mean_purity,mean_accuracy,mean_f1,mean_precision,mean_recall,mean_entropy]
metrics_list=[mean_h,mean_c,mean_v,mean_ari,mean_ami,mean_nmi,mean_purity,mean_accuracy,mean_f1,mean_precision,mean_recall,mean_entropy,mean_time]
save_results(args,metrics_list)

###### Report Final Results ######
Expand Down Expand Up @@ -281,7 +287,7 @@ def parse_args():
if __name__ == '__main__':
args = parse_args()
if args.cuda:
torch.cuda.set_device(4)
torch.cuda.set_device(1)
# torch.cuda.manual_seed(args.seed)
# random.seed(args.seed)
# np.random.seed(args.seed)
Expand Down
11 changes: 9 additions & 2 deletions daegce.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def training(args):
mean_precision=[]
mean_recall = []
mean_entropy = []
mean_time= []


if args.cuda>=0:
Expand Down Expand Up @@ -140,6 +141,7 @@ def training(args):

loss_list=None
pretrain_flag = False
start_time = time.time()
for epoch in range(args.epochs):
t = time.time()
model.train()
Expand Down Expand Up @@ -202,9 +204,12 @@ def training(args):
# "val_edge_ap=", "{:.5f}".format(ap_curr),
# "val_attr_roc=", "{:.5f}".format(roc_curr_a),
# "val_attr_ap=", "{:.5f}".format(ap_curr_a),
"time=", "{:.5f}".format(time.time() - t))
"time=", "{:.5f}".format(time.time() - t),
"total time=", "{:.5f}".format(time.time() - start_time))

print("Optimization Finished!")
end_time = time.time()
print("total time spend:", end_time- start_time)

pre,gamma_c = model.predict_soft_assignment(z)

Expand Down Expand Up @@ -234,11 +239,13 @@ def training(args):
mean_precision.append(round(precision,4))
mean_recall.append(round(recall,4))
mean_entropy.append(round(entropy,4))
mean_time.append(round(end_time-start_time,4))

plot_tsne(args.dataset,args.model,epoch,z.cpu(),model.mu_c.cpu(),tru,pre)


metrics_list=[mean_h,mean_c,mean_v,mean_ari,mean_ami,mean_nmi,mean_purity,mean_accuracy,mean_f1,mean_precision,mean_recall,mean_entropy]
# metrics_list=[mean_h,mean_c,mean_v,mean_ari,mean_ami,mean_nmi,mean_purity,mean_accuracy,mean_f1,mean_precision,mean_recall,mean_entropy]
metrics_list=[mean_h,mean_c,mean_v,mean_ari,mean_ami,mean_nmi,mean_purity,mean_accuracy,mean_f1,mean_precision,mean_recall,mean_entropy,mean_time]
save_results(args, metrics_list)
###### Report Final Results ######
print('Homogeneity:{}\t mean:{}\t std:{}\n'.format(mean_h,round(np.mean(mean_h),4),round(np.std(mean_h),4)))
Expand Down
3,106 changes: 3,106 additions & 0 deletions gcn_ae_flickr_log

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions gcn_can_flickr_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
nohup: ignoring input
Using Flickr dataset
dataset:Flickr, node_num:7575,edge_num:479476,attribute_num:12047
imported graph edge number (without selfloop):239738.0
cluster number:9
node size:7575, feature size:12047
graph edge number after mask:239738.0
graph edge number after normalize adjacent matrix:239738.0
Traceback (most recent call last):
File "can.py", line 289, in <module>
training(args)
File "can.py", line 159, in training
loss_list,[mu_u, logvar_u, mu_a, logvar_a,z] = model.loss(features_training,adj_norm,labels = (adj_label, features_label), n_nodes = n_nodes, n_features = n_features,norm = (norm_u, norm_a), pos_weight = (pos_weight_u, pos_weight_a))
File "/home/syang/project/github_code/node-clustering/model.py", line 716, in loss
cost_a = norm_a * F.binary_cross_entropy_with_logits(pred_x, labels_sub_a, pos_weight = pos_weight_a)
File "/home/syang/anaconda3/lib/python3.7/site-packages/torch/nn/functional.py", line 2435, in binary_cross_entropy_with_logits
return torch.binary_cross_entropy_with_logits(input, target, weight, pos_weight, reduction_enum)
RuntimeError: CUDA out of memory. Tried to allocate 350.00 MiB (GPU 0; 31.75 GiB total capacity; 3.39 GiB already allocated; 34.50 MiB free; 3.41 GiB reserved in total by PyTorch)
Loading

0 comments on commit d2c716a

Please sign in to comment.