1
1
import argparse
2
2
import os
3
3
import os .path as osp
4
- import uuid
5
- from pprint import pprint
6
4
7
5
import const
8
6
from const import *
9
7
10
- if platform .system () == "Windows" :
11
- DEVICE = "cuda:0"
8
+ if platform .system () in [ "Windows" , "Linux" ] :
9
+ import torch
12
10
13
- elif platform .system () == "Linux" :
14
- DEVICE = "cuda:0"
11
+ if torch .cuda .is_available ():
12
+ DEFAULT_DEVICE = "cuda:0"
13
+ else :
14
+ DEFAULT_DEVICE = "cpu"
15
15
16
16
17
17
elif platform .system () == "Darwin" :
18
- DEVICE = "mps:0"
18
+ DEFAULT_DEVICE = "mps:0"
19
19
20
20
21
21
else :
22
22
raise NotImplementedError ("Unknown System" )
23
23
24
- print (f"Your system: { platform .system ()} . Default device: { DEVICE } " )
24
+ print (f"Your system: { platform .system ()} . Default device: { DEFAULT_DEVICE } " )
25
25
26
-
27
-
28
-
29
- parser = argparse .ArgumentParser (description = "Dynamic Graph Embedding Trajectory." )
26
+ parser = argparse .ArgumentParser (
27
+ description = "Dynamic Graph Embedding Trajectory." )
30
28
# Parameters for Analysis
31
29
parser .add_argument ('--do_visual' , action = 'store_true' ,
32
30
help = "Whether to do visualization" )
43
41
help = "Comment for each run. Useful for identifying each run on Tensorboard" )
44
42
parser .add_argument ('--data_dir' , type = str , default = "data" ,
45
43
help = "Location to store all the data." )
46
- parser .add_argument ('--dataset_name' , type = str , default = 'Chickenpox' , help = "Name of dataset." )
47
- parser . add_argument ( '--device' , type = str , default = DEVICE , help = "Device to use. When using multi-gpu, this is the 'master' device where all operations are performed ." )
48
- parser .add_argument ('--device2 ' , type = str , default = 'cpu' ,
49
- help = "For Multi-GPU training " )
44
+ parser .add_argument ('--dataset_name' , type = str , default = 'Chickenpox' ,
45
+ help = "Name of dataset ." )
46
+ parser .add_argument ('--device ' , type = str , default = DEFAULT_DEVICE ,
47
+ help = "Device to use. When using multi-gpu, this is the 'master' device where all operations are performed. " )
50
48
51
49
parser .add_argument ('--do_test' , action = 'store_true' )
52
50
parser .add_argument ('--do_val' , action = 'store_true' )
53
- parser .add_argument ('--do_weighted' , action = 'store_true' , help = "Construct weighted graph instead of multigraph for each graph snapshot" )
51
+ parser .add_argument ('--do_weighted' , action = 'store_true' ,
52
+ help = "Construct weighted graph instead of multigraph for each graph snapshot" )
54
53
55
54
parser .add_argument ('--dropout' , type = float , default = 0.1 ,
56
55
help = "Dropout rate (1 - keep probability)." )
57
56
58
-
59
- parser .add_argument ('--embedding_dim' , type = int , default = 64 , help = "the embedding size of model" )
60
- parser .add_argument ('--embedding_dim_user' , type = int , default = 32 , help = "The embedding size for the users" )
61
- parser .add_argument ('--embedding_dim_resource' , type = int , default = 32 , help = "The embedding size for the resource (e.g. video)" )
57
+ parser .add_argument ('--embedding_dim' , type = int , default = 64 ,
58
+ help = "the embedding size of model" )
59
+ parser .add_argument ('--embedding_dim_user' , type = int , default = 32 ,
60
+ help = "The embedding size for the users" )
61
+ parser .add_argument ('--embedding_dim_resource' , type = int , default = 32 ,
62
+ help = "The embedding size for the resource (e.g. video)" )
62
63
63
64
parser .add_argument ('--epochs' , type = int , default = 50 ,
64
65
help = "Number of epochs to train." )
85
86
86
87
parser .add_argument ('--i_end' , type = int , default = None ,
87
88
help = "Index of the end dataset." )
88
-
89
+ parser .add_argument ('--in_channels' , type = int , default = None ,
90
+ help = "Index of the end dataset." )
89
91
90
92
parser .add_argument ('--lr' , type = float , default = 1e-3 , help = "Learning rate" )
91
93
parser .add_argument ('--max_seq_length' , type = int , default = 128 ,
92
94
help = "Maximum sequence length" )
93
95
94
- parser .add_argument ('--model' , type = str , default = None , help = "Model Name " )
96
+ parser .add_argument ('--model' , type = str , default = None , help = "Model name " )
95
97
96
- parser .add_argument ('--node_types' , type = str , choices = ["v_subreddit" , "author_subreddit" , "author_resource" ], default = "v_subreddit" ,
98
+ parser .add_argument ('--node_types' , type = str ,
99
+ choices = ["v_subreddit" , "author_subreddit" ,
100
+ "author_resource" ], default = "v_subreddit" ,
97
101
help = "What types of node to include in the GCN bipartite graph?" )
98
102
99
103
parser .add_argument ('--num_negative_candidates' , type = int , default = 1000 ,
100
104
help = "How many negative examples to sample for each video during the initial sampling?" )
101
- parser .add_argument ('--num_neighbors' , type = int , default = 10 , help = "Number of neighboring nodes in GNN" )
105
+ parser .add_argument ('--num_neighbors' , type = int , default = 10 ,
106
+ help = "Number of neighboring nodes in GNN" )
102
107
parser .add_argument ('--num_resource_prototypes' , type = int , default = - 1 , help = "" )
103
108
104
- parser .add_argument ('--num_workers' , type = int , default = 1 , help = "Number of workers for multiprocessing" )
105
- parser .add_argument ('--perplexity' , type = int , default = 20 , help = "Perplexity of the generated t-SNE plot" )
109
+ parser .add_argument ('--num_workers' , type = int , default = 1 ,
110
+ help = "Number of workers for multiprocessing" )
111
+ parser .add_argument ('--perplexity' , type = int , default = 20 ,
112
+ help = "Perplexity of the generated t-SNE plot" )
106
113
parser .add_argument ('--pretrained_embeddings_epoch' , type = int , default = 195 ,
107
114
help = "Which epoch of the pretrained embeddings (Node2Vec, GCN ...) to use" )
108
115
parser .add_argument ('--output_dir' , type = str , default = "outputs" )
122
129
parser .add_argument ('--num_sample_author' , type = int , default = - 1 ,
123
130
help = "Number of resource to sample in our dataset. Set to -1 if we do not want to sample" )
124
131
125
-
126
-
127
-
128
132
parser .add_argument ('--port' , type = int , default = 8050 )
129
133
130
-
131
134
parser .add_argument ('--save_embed_every' , type = int , default = 10 ,
132
135
help = "How many epochs to save embeddings for visualization?" )
133
136
134
- parser .add_argument ('--save_resource_embed' , action = 'store_true' ,
135
- help = "Whether to save the embeddings for resources (videos, URLs, Misinformative URLs)?" )
136
-
137
-
138
137
parser .add_argument ('--save_model_every' , type = int , default = - 1 ,
139
138
help = "How many epochs to save the model weights?" )
140
139
parser .add_argument ('--seed' , type = int , default = 42 , help = "Random seed." )
154
153
parser .add_argument ('--snapshot_interval' , type = int , default = 1 ,
155
154
help = "Time interval (in days) between each snapshot. Default: 1 month. Interactions happening within this time interval will be grouped into one snapshot." )
156
155
156
+ parser .add_argument ('--transform_input' , action = 'store_true' ,
157
+ help = "Whether to transform the input to a new embedding space. This field is automatically set to True if in_channels does not equal to embedding_dim" )
158
+
157
159
parser .add_argument ('--suffix' , type = str , default = "" ,
158
160
help = "Suffix to append to the end of the log file name" )
159
161
160
- parser .add_argument ('--visualization_dim' , type = int , choices = [2 , 3 ], default = 2 , help = "Dimension of the generated visualization. Can be 2- or 3-dimensional." )
162
+ parser .add_argument ('--tasks' , type = str ,
163
+ default = "['node_classification','link_pred']" ,
164
+ help = "Tasks to run, passed as a list of strings" )
165
+
166
+ parser .add_argument ('--visualization_dim' , type = int , choices = [2 , 3 ], default = 2 ,
167
+ help = "Dimension of the generated visualization. Can be 2- or 3-dimensional." )
161
168
162
- parser .add_argument ('--visualization_model' , type = str , choices = [const .TSNE , const .UMAP , const .PCA , const .ISOMAP , const .MDS ], default = const .TSNE ,
169
+ parser .add_argument ('--visualization_model' , type = str ,
170
+ choices = [const .TSNE , const .UMAP , const .PCA , const .ISOMAP ,
171
+ const .MDS ], default = const .TSNE ,
163
172
help = "Visualization model to use" )
164
173
165
174
args = parser .parse_args ()
166
175
176
+ if args .in_channels is None :
177
+ args .in_channels = args .embedding_dim
167
178
args .num_nearest_neighbors = eval (args .num_nearest_neighbors )
168
179
169
180
args .visual_dir = osp .join (args .output_dir , "visual" , args .dataset_name )
170
- os .makedirs (args .visual_dir , exist_ok = True )
181
+ os .makedirs (args .visual_dir , exist_ok = True )
182
+
183
+ args .transform_input = args .in_channels != args .embedding_dim
184
+ args .tasks = eval (args .tasks )
185
+ print (args .tasks )
0 commit comments