-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmnist_baseline.py
45 lines (38 loc) · 1.03 KB
/
mnist_baseline.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
from argparse import ArgumentError
import logging
from runner import run
from models import MLP, ResNet
from datasets import mnistBaselineLoader
from easydict import EasyDict
from train_utils import checkSavedModel
logger = logging.getLogger()
params = EasyDict()
params.savepoint = "baseline"
params.modelType = "ResNet"
params.resume = True
params.name = "mnist"
params.epochs = 10
params.lr = 0.001
params.batchSize = 16 # 128
params.schedule = [6, 8, 16]
params.gamma = 0.5
params.alpha = 0.49
params.angle = 60
params.evals = ["alphaBlending", "rotation"]
params.metricParams = {
"n_steps": 50,
"minPixelValue": 1e-5,
"minProb": 0.0,
"patchSize": 2,
"nConform": 50,
}
if __name__ == "__main__":
logger.info(params)
if params.modelType == "MLP":
model = MLP()
elif params.modelType == "ResNet":
model = ResNet(1)
else:
raise ArgumentError(f"Invalid model type: {params.modelType}")
params.modelIsTrained = checkSavedModel(params, model)
run(params, model, mnistBaselineLoader)