forked from PPPLDeepLearning/plasma-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhyper_learn.py
More file actions
42 lines (34 loc) · 1.53 KB
/
hyper_learn.py
File metadata and controls
42 lines (34 loc) · 1.53 KB
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
from __future__ import print_function
import numpy as np
from hyperopt import Trials, tpe
from plasma.conf import conf
from pprint import pprint
pprint(conf)
#from plasma.primitives.shots import Shot, ShotList
from plasma.preprocessor.normalize import Normalizer
from plasma.models.loader import Loader
#from plasma.models.runner import train, make_predictions,make_predictions_gpu
if conf['data']['normalizer'] == 'minmax':
from plasma.preprocessor.normalize import MinMaxNormalizer as Normalizer
elif conf['data']['normalizer'] == 'meanvar':
from plasma.preprocessor.normalize import MeanVarNormalizer as Normalizer
elif conf['data']['normalizer'] == 'var':
from plasma.preprocessor.normalize import VarNormalizer as Normalizer #performs !much better than minmaxnormalizer
elif conf['data']['normalizer'] == 'averagevar':
from plasma.preprocessor.normalize import AveragingVarNormalizer as Normalizer #performs !much better than minmaxnormalizer
else:
print('unkown normalizer. exiting')
exit(1)
np.random.seed(1)
print("normalization",end='')
nn = Normalizer(conf)
nn.train()
loader = Loader(conf,nn)
shot_list_train,shot_list_validate,shot_list_test = loader.load_shotlists(conf)
print("...done")
print('Training on {} shots, testing on {} shots'.format(len(shot_list_train),len(shot_list_test)))
from plasma.models import runner
specific_runner = runner.HyperRunner(conf,loader,shot_list_train)
best_run, best_model = specific_runner.frnn_minimize(algo=tpe.suggest,max_evals=2,trials=Trials())
print (best_run)
print (best_model)