MCPcopy Index your code
hub / github.com/InternScience/InternAgent / main

Function main

tasks/AutoTPPR/code/experiment.py:1375–1416  ·  view source on GitHub ↗
(data_path='./data', out_dir='./saved_models', device='cuda:0')

Source from the content-addressed store, hash-verified

1373
1374
1375def main(data_path='./data', out_dir='./saved_models', device='cuda:0'):
1376 os.makedirs(data_path, exist_ok=True)
1377 os.makedirs(out_dir, exist_ok=True)
1378
1379 os.environ["WANDB_SILENT"] = "true"
1380 os.environ["WANDB_ERROR_REPORTING"] = "false"
1381
1382 print_sys("=== data loading ===")
1383 pert_data = PertData(data_path)
1384
1385 pert_data.load(data_name='norman')
1386
1387 pert_data.prepare_split(split='simulation', seed=1)
1388 pert_data.get_dataloader(batch_size=32, test_batch_size=128)
1389
1390 print_sys("\n=== model traing ===")
1391 gears_model = GEARS(
1392 pert_data,
1393 device=device,
1394 weight_bias_track=True,
1395 proj_name='GEARS',
1396 exp_name='gears_norman'
1397 )
1398 gears_model.model_initialize(hidden_size = 64)
1399
1400 gears_model.train(epochs=args.epochs, lr=1e-3)
1401
1402 gears_model.save_model(os.path.join(out_dir, 'norman_full_model'))
1403 print_sys(f"model saved to {out_dir}")
1404 gears_model.load_pretrained(os.path.join(out_dir, 'norman_full_model'))
1405
1406 final_infos = {
1407 "Gears":{
1408 "means":{
1409 "Test Top 20 DE MSE": float(gears_model.test_metrics['mse_de'].item())
1410 }
1411 }
1412 }
1413
1414 with open(os.path.join(out_dir, 'final_info.json'), 'w') as f:
1415 json.dump(final_infos, f, indent=4)
1416 print_sys("final info saved.")
1417
1418def print_sys(s):
1419 """system print

Callers 1

experiment.pyFile · 0.70

Calls 11

loadMethod · 0.95
prepare_splitMethod · 0.95
get_dataloaderMethod · 0.95
model_initializeMethod · 0.95
trainMethod · 0.95
save_modelMethod · 0.95
load_pretrainedMethod · 0.95
print_sysFunction · 0.70
PertDataClass · 0.70
GEARSClass · 0.70
dumpMethod · 0.45

Tested by

no test coverage detected