comparison deep/stacked_dae/v_sylvain/nist_sda.py @ 238:9fc641d7adda

Possibilite de restreindre la taille des ensemble d'entrainement, valid et test afin de pouvoir tester le code rapidement
author SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
date Mon, 15 Mar 2010 13:22:20 -0400
parents ecb69e17950b
children 6d49cf134a40
comparison
equal deleted inserted replaced
237:9b6e0af062af 238:9fc641d7adda
47 47
48 if TEST_CONFIG: 48 if TEST_CONFIG:
49 REDUCE_TRAIN_TO = 1000 49 REDUCE_TRAIN_TO = 1000
50 MAX_FINETUNING_EPOCHS = 2 50 MAX_FINETUNING_EPOCHS = 2
51 REDUCE_EVERY = 10 51 REDUCE_EVERY = 10
52 MINIBATCH_SIZE=20
52 53
53 # Possible values the hyperparameters can take. These are then 54 # Possible values the hyperparameters can take. These are then
54 # combined with produit_cartesien_jobs so we get a list of all 55 # combined with produit_cartesien_jobs so we get a list of all
55 # possible combinations, each one resulting in a job inserted 56 # possible combinations, each one resulting in a job inserted
56 # in the jobman DB. 57 # in the jobman DB.
69 'pretraining_epochs_per_layer':2, 70 'pretraining_epochs_per_layer':2,
70 'max_finetuning_epochs':2, 71 'max_finetuning_epochs':2,
71 'hidden_layers_sizes':500, 72 'hidden_layers_sizes':500,
72 'corruption_levels':0.2, 73 'corruption_levels':0.2,
73 'minibatch_size':20, 74 'minibatch_size':20,
74 #'reduce_train_to':10000, 75 'reduce_train_to':10000,
75 'num_hidden_layers':1}) 76 'num_hidden_layers':1})
76 77
77 ''' 78 '''
78 Function called by jobman upon launching each job 79 Function called by jobman upon launching each job
79 Its path is the one given when inserting jobs: see EXPERIMENT_PATH 80 Its path is the one given when inserting jobs: see EXPERIMENT_PATH
92 ## 93 ##
93 ## nist = NIST(minibatch_size=20) 94 ## nist = NIST(minibatch_size=20)
94 ## 95 ##
95 ## print "NIST loaded" 96 ## print "NIST loaded"
96 ## 97 ##
97 ## # For test runs, we don't want to use the whole dataset so 98 # For test runs, we don't want to use the whole dataset so
98 ## # reduce it to fewer elements if asked to. 99 # reduce it to fewer elements if asked to.
99 ## rtt = None 100 rtt = None
100 ## if state.has_key('reduce_train_to'): 101 if state.has_key('reduce_train_to'):
101 ## rtt = state['reduce_train_to'] 102 rtt = int(state['reduce_train_to']/state['minibatch_size'])
102 ## elif REDUCE_TRAIN_TO: 103 elif REDUCE_TRAIN_TO:
103 ## rtt = REDUCE_TRAIN_TO 104 rtt = int(REDUCE_TRAIN_TO/MINIBATCH_SIZE)
104 ## 105
105 ## if rtt: 106 if rtt:
106 ## print "Reducing training set to "+str(rtt)+ " examples" 107 print "Reducing training set to "+str(rtt*state['minibatch_size'])+ " examples"
108 else:
109 rtt=float('inf') #No reduction
107 ## nist.reduce_train_set(rtt) 110 ## nist.reduce_train_set(rtt)
108 ## 111 ##
109 ## train,valid,test = nist.get_tvt() 112 ## train,valid,test = nist.get_tvt()
110 ## dataset = (train,valid,test) 113 ## dataset = (train,valid,test)
111 114
112 n_ins = 32*32 115 n_ins = 32*32
113 n_outs = 62 # 10 digits, 26*2 (lower, capitals) 116 n_outs = 62 # 10 digits, 26*2 (lower, capitals)
114 117
115 series = create_series(state.num_hidden_layers) 118 series = create_series(state.num_hidden_layers)
116 119
117 print "Creating optimizer with state, ", state 120 print "Creating optimizer with state, ", state
118 121
119 optimizer = SdaSgdOptimizer(dataset=datasets.nist_all, hyperparameters=state, \ 122 optimizer = SdaSgdOptimizer(dataset=datasets.nist_all, hyperparameters=state, \
120 n_ins=n_ins, n_outs=n_outs,\ 123 n_ins=n_ins, n_outs=n_outs,\
121 series=series) 124 series=series)
122 125
123 optimizer.pretrain(datasets.nist_all) 126 optimizer.pretrain(datasets.nist_all,rtt)
124 channel.save() 127 channel.save()
125 128
126 optimizer.finetune(datasets.nist_all) 129 optimizer.finetune(datasets.nist_all,rtt)
127 channel.save() 130 channel.save()
128 131
129 return channel.COMPLETE 132 return channel.COMPLETE
130 133
131 # These Series objects are used to save various statistics 134 # These Series objects are used to save various statistics