(dataset, times)
| 212 | |
| 213 | |
| 214 | def 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 | |
| 259 | if __name__ == '__main__': |
no test coverage detected