Mercurial > ift6266
comparison deep/stacked_dae/v_sylvain/nist_sda.py @ 318:8de3bef71458
Ajoute plus de fonctionnalite
author | SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca> |
---|---|
date | Fri, 02 Apr 2010 09:12:40 -0400 |
parents | bd6085d77706 |
children | 7a12d2c3d06b |
comparison
equal
deleted
inserted
replaced
317:067e747fd9c0 | 318:8de3bef71458 |
---|---|
53 | 53 |
54 n_ins = 32*32 | 54 n_ins = 32*32 |
55 n_outs = 62 # 10 digits, 26*2 (lower, capitals) | 55 n_outs = 62 # 10 digits, 26*2 (lower, capitals) |
56 | 56 |
57 examples_per_epoch = NIST_ALL_TRAIN_SIZE | 57 examples_per_epoch = NIST_ALL_TRAIN_SIZE |
58 | 58 |
59 series = create_series(state.num_hidden_layers) | 59 #To be sure variables will not be only in the if statement |
60 PATH = '' | |
61 nom_reptrain = '' | |
62 nom_serie = "" | |
63 if state['pretrain_choice'] == 0: | |
64 nom_serie="series_NIST.h5" | |
65 elif state['pretrain_choice'] == 1: | |
66 nom_serie="series_P07.h5" | |
67 | |
68 series = create_series(state.num_hidden_layers,nom_serie) | |
69 | |
60 | 70 |
61 print "Creating optimizer with state, ", state | 71 print "Creating optimizer with state, ", state |
62 | 72 |
63 optimizer = SdaSgdOptimizer(dataset=datasets.nist_all(), | 73 optimizer = SdaSgdOptimizer(dataset=datasets.nist_all(), |
64 hyperparameters=state, \ | 74 hyperparameters=state, \ |
125 optimizer.reload_parameters('params_pretrain.txt') | 135 optimizer.reload_parameters('params_pretrain.txt') |
126 optimizer.finetune(datasets.nist_all(),datasets.nist_P07(),max_finetune_epoch_NIST,ind_test=1,special=1) | 136 optimizer.finetune(datasets.nist_all(),datasets.nist_P07(),max_finetune_epoch_NIST,ind_test=1,special=1) |
127 | 137 |
128 | 138 |
129 if finetune_choice==-1: | 139 if finetune_choice==-1: |
130 print('\nSERIE OF 3 DIFFERENT FINETUNINGS') | 140 print('\nSERIE OF 4 DIFFERENT FINETUNINGS') |
131 print('\n\n\tfinetune with NIST\n\n') | 141 print('\n\n\tfinetune with NIST\n\n') |
142 sys.stdout.flush() | |
132 optimizer.reload_parameters('params_pretrain.txt') | 143 optimizer.reload_parameters('params_pretrain.txt') |
133 optimizer.finetune(datasets.nist_all(),datasets.nist_P07(),max_finetune_epoch_NIST,ind_test=1) | 144 optimizer.finetune(datasets.nist_all(),datasets.nist_P07(),max_finetune_epoch_NIST,ind_test=1) |
134 channel.save() | 145 channel.save() |
135 print('\n\n\tfinetune with P07\n\n') | 146 print('\n\n\tfinetune with P07\n\n') |
147 sys.stdout.flush() | |
136 optimizer.reload_parameters('params_pretrain.txt') | 148 optimizer.reload_parameters('params_pretrain.txt') |
137 optimizer.finetune(datasets.nist_P07(),datasets.nist_all(),max_finetune_epoch_P07,ind_test=0) | 149 optimizer.finetune(datasets.nist_P07(),datasets.nist_all(),max_finetune_epoch_P07,ind_test=0) |
138 channel.save() | 150 channel.save() |
139 print('\n\n\tfinetune with NIST (done earlier) followed by P07 (written here)\n\n') | 151 print('\n\n\tfinetune with NIST (done earlier) followed by P07 (written here)\n\n') |
152 sys.stdout.flush() | |
140 optimizer.reload_parameters('params_finetune_NIST.txt') | 153 optimizer.reload_parameters('params_finetune_NIST.txt') |
141 optimizer.finetune(datasets.nist_P07(),datasets.nist_all(),max_finetune_epoch_P07,ind_test=20) | 154 optimizer.finetune(datasets.nist_P07(),datasets.nist_all(),max_finetune_epoch_P07,ind_test=20) |
142 channel.save() | 155 channel.save() |
143 print('\n\n\tfinetune with NIST only on the logistic regression on top.\n\ | 156 print('\n\n\tfinetune with NIST only on the logistic regression on top.\n\ |
144 All hidden units output are input of the logistic regression\n\n') | 157 All hidden units output are input of the logistic regression\n\n') |
158 sys.stdout.flush() | |
145 optimizer.reload_parameters('params_pretrain.txt') | 159 optimizer.reload_parameters('params_pretrain.txt') |
146 optimizer.finetune(datasets.nist_all(),datasets.nist_P07(),max_finetune_epoch_NIST,ind_test=1,special=1) | 160 optimizer.finetune(datasets.nist_all(),datasets.nist_P07(),max_finetune_epoch_NIST,ind_test=1,special=1) |
147 channel.save() | 161 channel.save() |
148 | 162 |
149 channel.save() | 163 channel.save() |
150 | 164 |
151 return channel.COMPLETE | 165 return channel.COMPLETE |
152 | 166 |
153 # These Series objects are used to save various statistics | 167 # These Series objects are used to save various statistics |
154 # during the training. | 168 # during the training. |
155 def create_series(num_hidden_layers): | 169 def create_series(num_hidden_layers, nom_serie): |
156 | 170 |
157 # Replace series we don't want to save with DummySeries, e.g. | 171 # Replace series we don't want to save with DummySeries, e.g. |
158 # series['training_error'] = DummySeries() | 172 # series['training_error'] = DummySeries() |
159 | 173 |
160 series = {} | 174 series = {} |
161 | 175 |
162 basedir = os.getcwd() | 176 basedir = os.getcwd() |
163 | 177 |
164 h5f = tables.openFile(os.path.join(basedir, "series.h5"), "w") | 178 h5f = tables.openFile(os.path.join(basedir, nom_serie), "w") |
165 | 179 |
166 # reconstruction | 180 # reconstruction |
167 reconstruction_base = \ | 181 reconstruction_base = \ |
168 ErrorSeries(error_name="reconstruction_error", | 182 ErrorSeries(error_name="reconstruction_error", |
169 table_name="reconstruction_error", | 183 table_name="reconstruction_error", |