-
Notifications
You must be signed in to change notification settings - Fork 3
/
train_script.py
51 lines (38 loc) · 1.56 KB
/
train_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import json
from transformer_ee.train import MVtrainer
with open("transformer_ee/config/input_dune.json", encoding="UTF-8", mode="r") as f:
input_d = json.load(f)
## Set the path to the input data
# input_d["data_path"]="transformer_ee/data/dataset_lstm_ee_nd_rhc_nonswap_loose_cut.csv.xz"
## Set the number of workers in dataloader. The more workers, the faster the data loading. But it may consume more memory.
input_d["num_workers"] = 10
## Set the model hyperparameters
# input_d["model"]["kwargs"]["nhead"] = 12
input_d["model"]["epochs"] = 20
input_d["model"]["kwargs"]["num_layers"] = 5
## Set the optimizer
input_d["optimizer"]["name"] = "sgd"
input_d["optimizer"]["kwargs"]["lr"] = 0.01
input_d["optimizer"]["kwargs"]["momentum"] = 0.9
## Set the path to save the model
input_d["save_path"] = "save/model/test"
## Set the weighter
# input_d["weight"] = {"name": "FlatSpectraWeights", "kwargs": {"maxweight": 5, "minweight": 0.2}}
input_d["dataframe_type"] = "polars"
## Example of adding noise to the input variables
# input_d["noise"] = {
# "name": "gaussian",
# "mean": 0,
# "std": 0.2,
# "vector": ["particle.energy", "particle.calE", "particle.nHit"],
# "scalar": ["event.calE", "event.nHits"],
# }
## Example of using WandBLogger
# from transformer_ee.logger.wandb_train_logger import WandBLogger
# my_logger = WandBLogger(
# project="test", entity="neutrinoenenergyestimators", config=input_d, dir="save", id="testrun"
# )
# my_trainer = MVtrainer(input_d, logger=my_logger)
my_trainer = MVtrainer(input_d)
my_trainer.train()
my_trainer.eval()