-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmy_examples.py
More file actions
56 lines (50 loc) · 1.67 KB
/
my_examples.py
File metadata and controls
56 lines (50 loc) · 1.67 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import my_exp_config as mec
from easydict import EasyDict as edict
from os import path as osp
####### EXAMPLE 1 - CONFIGURING AN MNIST EXPERIMENT #########
##
#Define the experiment, snapshot and other required paths
def get_mnist_paths():
paths = edict()
#Path to store experiment details
paths.exp = edict()
paths.exp.dr = './test_data/mnist/exp'
#Paths to store snapshot details
paths.exp.snapshot = edict()
paths.exp.snapshot.dr = './test_data/mnist/snapshots'
return paths
##
#Define any parameters that may influence the experiment details
def get_mnist_prms():
prms = edict()
prms['expStr'] = 'mnist'
prms.paths = get_mnist_paths()
return prms
##
#Setup a scratch experiment
def setup_experiment():
prms = get_mnist_prms()
nwPrms = {'netName': 'MyNet',
'baseNetDefProto': 'trainval.prototxt'}
cPrms = mec.get_caffe_prms(mec.get_default_net_prms, nwPrms,
mec.get_default_solver_prms,
baseDefDir='./test_data/mnist')
exp = mec.CaffeSolverExperiment(prms, cPrms)
exp.make()
return exp
####### END OF EXAMPLE 1 ###################
####### Example 2 - FINETUNING MNIST EXPERIMENT ###########
def setup_experiment_finetune():
prms = get_mnist_prms()
preTrainNet = './test_data/mnist/mnist-test_iter_4000.caffemodel'
#preTrainNet = None
baseDefDir ='./test_data/mnist'
nwPrms = {'netName': 'MyNet',
'baseNetDefProto': osp.join(baseDefDir, 'trainval.prototxt'),
'preTrainNet': preTrainNet}
cPrms = mec.get_caffe_prms(mec.get_default_net_prms, nwPrms,
mec.get_default_solver_prms)
exp = mec.CaffeSolverExperiment(prms, cPrms)
exp.make()
return exp
####### END OF EXAMPLE 2 ###################