MCPcopy Create free account
hub / github.com/chengsen/PyTorch_TextGCN / main

Function main

trainer.py:214–256  ·  view source on GitHub ↗
(dataset, times)

Source from the content-addressed store, hash-verified

212
213
214def main(dataset, times):
215 args = parameter_parser()
216 args.dataset = dataset
217
218 args.device = th.device('cuda') if th.cuda.is_available() else th.device('cpu')
219 args.nhid = 200
220 args.max_epoch = 200
221 args.dropout = 0.5
222 args.val_ratio = 0.1
223 args.early_stopping = 10
224 args.lr = 0.02
225 model = GCN
226
227 print(args)
228
229 predata = PrepareData(args)
230 cudause = CudaUse()
231
232 record = LogResult()
233 seed_lst = list()
234 for ind, seed in enumerate(return_seed(times)):
235 print(f"\n\n==> {ind}, seed:{seed}")
236 args.seed = seed
237 seed_lst.append(seed)
238
239 framework = TextGCNTrainer(model=model, args=args, pre_data=predata)
240 framework.fit()
241
242 if th.cuda.is_available():
243 gpu_mem = cudause.gpu_mem_get(_id=0)
244 record.log_single(key="gpu_mem", value=gpu_mem)
245
246 record.log(framework.test())
247
248 del framework
249 gc.collect()
250
251 if th.cuda.is_available():
252 th.cuda.empty_cache()
253
254 print("==> seed set:")
255 print(seed_lst)
256 record.show_str()
257
258
259if __name__ == '__main__':

Callers 1

trainer.pyFile · 0.70

Calls 12

fitMethod · 0.95
gpu_mem_getMethod · 0.95
log_singleMethod · 0.95
logMethod · 0.95
testMethod · 0.95
show_strMethod · 0.95
parameter_parserFunction · 0.90
CudaUseClass · 0.90
LogResultClass · 0.90
return_seedFunction · 0.90
PrepareDataClass · 0.85
TextGCNTrainerClass · 0.85

Tested by

no test coverage detected