comparison deep/stacked_dae/nist_sda.py @ 191:3632e6258642

Ajouts mineurs à stacked_dae, juste printé l'heure je crois.
author fsavard
date Tue, 02 Mar 2010 14:47:18 -0500
parents d364a130b221
children e656edaedb48
comparison
equal deleted inserted replaced
190:70a9df1cd20e 191:3632e6258642
23 23
24 from utils import produit_croise_jobs 24 from utils import produit_croise_jobs
25 25
26 from sgd_optimization import SdaSgdOptimizer 26 from sgd_optimization import SdaSgdOptimizer
27 27
28 SERIES_AVAILABLE = False 28 from ift6266.utils.scalar_series import *
29 try:
30 from scalar_series import *
31 SERIES_AVAILABLE = True
32 except ImportError:
33 print "Could not import Series"
34 29
35 TEST_CONFIG = False 30 TEST_CONFIG = False
36 31
37 NIST_ALL_LOCATION = '/data/lisa/data/nist/by_class/all' 32 NIST_ALL_LOCATION = '/data/lisa/data/nist/by_class/all'
38 33
39 JOBDB = 'postgres://ift6266h10@gershwin/ift6266h10_db/fsavard_sda2' 34 JOBDB = 'postgres://ift6266h10@gershwin/ift6266h10_sandbox_db/fsavard_sda2'
40 35
41 REDUCE_TRAIN_TO = None 36 REDUCE_TRAIN_TO = None
42 MAX_FINETUNING_EPOCHS = 1000 37 MAX_FINETUNING_EPOCHS = 1000
43 REDUCE_EVERY = 1000 # number of minibatches before taking means for valid error etc. 38 REDUCE_EVERY = 1000 # number of minibatches before taking means for valid error etc.
44 if TEST_CONFIG: 39 if TEST_CONFIG:
56 'max_finetuning_epochs':[MAX_FINETUNING_EPOCHS], 51 'max_finetuning_epochs':[MAX_FINETUNING_EPOCHS],
57 'finetuning_lr':[0.1, 0.01], #0.001 was very bad, so we leave it out 52 'finetuning_lr':[0.1, 0.01], #0.001 was very bad, so we leave it out
58 'num_hidden_layers':[2,3]} 53 'num_hidden_layers':[2,3]}
59 54
60 # Just useful for tests... minimal number of epochs 55 # Just useful for tests... minimal number of epochs
61 DEFAULT_HP_NIST = DD({'finetuning_lr':0.01, 56 DEFAULT_HP_NIST = DD({'finetuning_lr':0.1,
62 'pretraining_lr':0.01, 57 'pretraining_lr':0.1,
63 'pretraining_epochs_per_layer':1, 58 'pretraining_epochs_per_layer':20,
64 'max_finetuning_epochs':1, 59 'max_finetuning_epochs':2,
65 'hidden_layers_sizes':1000, 60 'hidden_layers_sizes':300,
66 'corruption_levels':0.2, 61 'corruption_levels':0.2,
67 'minibatch_size':20, 62 'minibatch_size':20,
68 'reduce_train_to':1000, 63 #'reduce_train_to':300,
69 'num_hidden_layers':1}) 64 'num_hidden_layers':2})
70 65
71 def jobman_entrypoint(state, channel): 66 def jobman_entrypoint(state, channel):
72 pylearn.version.record_versions(state,[theano,ift6266,pylearn]) 67 pylearn.version.record_versions(state,[theano,ift6266,pylearn])
73 channel.save() 68 channel.save()
74 69
75 workingdir = os.getcwd() 70 workingdir = os.getcwd()
76 71
77 print "Will load NIST" 72 print "Will load NIST"
78 sys.stdout.flush()
79 73
80 nist = NIST(20) 74 nist = NIST(20)
81 75
82 print "NIST loaded" 76 print "NIST loaded"
83 sys.stdout.flush()
84 77
85 rtt = None 78 rtt = None
86 if state.has_key('reduce_train_to'): 79 if state.has_key('reduce_train_to'):
87 rtt = state['reduce_train_to'] 80 rtt = state['reduce_train_to']
88 elif REDUCE_TRAIN_TO: 81 elif REDUCE_TRAIN_TO:
89 rtt = REDUCE_TRAIN_TO 82 rtt = REDUCE_TRAIN_TO
90 83
91 if rtt: 84 if rtt:
92 print "Reducing training set to ", rtt, " examples" 85 print "Reducing training set to "+str( rtt)+ " examples"
93 nist.reduce_train_set(rtt) 86 nist.reduce_train_set(rtt)
94 87
95 train,valid,test = nist.get_tvt() 88 train,valid,test = nist.get_tvt()
96 dataset = (train,valid,test) 89 dataset = (train,valid,test)
97 90
105 state.corruption_levels = [cl] * nhl 98 state.corruption_levels = [cl] * nhl
106 99
107 # b,b',W for each hidden layer + b,W of last layer (logreg) 100 # b,b',W for each hidden layer + b,W of last layer (logreg)
108 numparams = nhl * 3 + 2 101 numparams = nhl * 3 + 2
109 series_mux = None 102 series_mux = None
110 if SERIES_AVAILABLE: 103 series_mux = create_series(workingdir, numparams)
111 series_mux = create_series(workingdir, numparams) 104
105 print "Creating optimizer with state, ", state
112 106
113 optimizer = SdaSgdOptimizer(dataset=dataset, hyperparameters=state, \ 107 optimizer = SdaSgdOptimizer(dataset=dataset, hyperparameters=state, \
114 n_ins=n_ins, n_outs=n_outs,\ 108 n_ins=n_ins, n_outs=n_outs,\
115 input_divider=255.0, series_mux=series_mux) 109 input_divider=255.0, series_mux=series_mux)
116 110
273 267
274 elif len(args) > 0 and args[0] == 'jobman_insert': 268 elif len(args) > 0 and args[0] == 'jobman_insert':
275 jobman_insert_nist() 269 jobman_insert_nist()
276 270
277 elif len(args) > 0 and args[0] == 'test_jobman_entrypoint': 271 elif len(args) > 0 and args[0] == 'test_jobman_entrypoint':
278 chanmock = DD({'COMPLETE':0}) 272 def f():
273 pass
274 chanmock = DD({'COMPLETE':0,'save':f})
279 jobman_entrypoint(DEFAULT_HP_NIST, chanmock) 275 jobman_entrypoint(DEFAULT_HP_NIST, chanmock)
280 276
281 elif len(args) > 0 and args[0] == 'estimate': 277 elif len(args) > 0 and args[0] == 'estimate':
282 estimate_total_time() 278 estimate_total_time()
283 else: 279 else: