Skip to content

Commit a3d8843

Browse files
committed
Fix:NP
1 parent 651de40 commit a3d8843

9 files changed

Lines changed: 23 additions & 36 deletions

File tree

sample_config/MNIST/CNN/model_conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"nnetType" : "CNN",
3-
"wdir" : "wdir",
3+
"wdir" : "MNIST_CNN",
44
"data_spec" : "data_spec.json",
55
"nnet_spec" : "nnet_spec.json",
66
"output_file" : "conv_out.model",
@@ -16,7 +16,7 @@
1616
"scale_by" : 0.5,
1717
"min_derror_decay_start" : 0.05,
1818
"min_derror_stop" : 0.0005,
19-
"min_epoch_decay_start" : 15
19+
"min_epoch_decay_start" : 5
2020
},
2121
"export_path":"data/cnn/",
2222
"plot_path":"plot/",

sample_config/MNIST/CNN/nnet_spec.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,12 @@
2626
"mlp" : {
2727
"hidden_layers": [50],
2828
"adv_activation" : null,
29-
"max_col_norm":null,
30-
"l1_reg":null,
31-
"l2_reg":null,
32-
"do_dropout" : true,
33-
"dropout_factor" : [0.2],
34-
"activation" : "tanh"
35-
},
36-
"a" : {
37-
"method":"maxout",
38-
"pool_size":1
39-
}
29+
"max_col_norm":null,
30+
"l1_reg":null,
31+
"l2_reg":null,
32+
"do_dropout" : true,
33+
"dropout_factor" : [0.2],
34+
"activation" : "tanh"
35+
}
4036

4137
}

sample_config/MNIST/DBN/model_conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"nnetType" : "RBM",
3-
"wdir" : "wdir",
3+
"wdir" : "MNIST_DBN",
44
"data_spec" : "data_spec.json",
55
"nnet_spec" : "rbm_spec.json",
66
"output_file" : "rbm_out.model",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{
3-
"hidden_layers": [1000, 1000, 1000],
3+
"hidden_layers": [500, 500],
44
"activation" : "sigmoid",
5-
"pretrained_layers" : 3,
5+
"pretrained_layers" : 2,
66
"first_layer_type" : "gb"
77
}

sample_config/MNIST/DNN/dnn_spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22

3-
"hidden_layers": [1000, 1000, 1000],
3+
"hidden_layers": [500, 500, 500],
44
"activation" : "sigmoid",
55
"pretrained_layers" : 3,
66
"max_col_norm":null,

sample_config/MNIST/SDA/model_conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"nnetType" : "SDA",
3-
"wdir" : "wdir",
3+
"wdir" : "MNIST_SDA",
44
"data_spec" : "data_spec.json",
55
"nnet_spec" : "sda_spec.json",
66
"output_file" : "sda_out.model",
@@ -16,7 +16,7 @@
1616
"finetune_params" : {
1717
"method":"C",
1818
"learning_rate" : 0.08,
19-
"epoch_num" : 10,
19+
"epoch_num" : 5,
2020
"start_rate" : 0.08,
2121
"scale_by" : 0.5,
2222
"min_derror_decay_start" : 0.05,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22

3-
"hidden_layers": [1000, 1000, 1000],
4-
"corruption_levels": [0.1, 0.2, 0.3],
3+
"hidden_layers": [500, 500],
4+
"corruption_levels": [0.1, 0.2],
55
"activation" : "tanh"
66
}

src/models/cnn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def plot_layer_output(self,plot_spec,plot_path,max_images=10):
141141
img_plot_remaining = max_images;
142142
layer_out_fn = self.getLayerOutFunction(layer_idx);
143143
logger.info('Plotting the layer %d'%layer_idx);
144-
file_reader =read_dataset(plot_spec,pad_zeros=True)[0];
144+
file_reader =read_dataset(plot_spec,pad_zeros=True);
145145
while not file_reader.is_finish():
146146
for batch_index in xrange(file_reader.cur_frame_num/batch_size):
147147
s_idx = batch_index * batch_size; e_idx = s_idx + batch_size
@@ -277,7 +277,7 @@ def __init__(self, numpy_rng, theano_rng, batch_size, n_outs,conv_layer_configs,
277277
dropout_conv_input = self.dropout_layers[-1].dropout_output;
278278

279279
config = conv_layer_configs[i]
280-
activation = conv_activation
280+
conv_activation= parse_activation(config['activation'])
281281
dropout_conv_layer = DropoutConvLayer(numpy_rng=numpy_rng, input=dropout_conv_input,
282282
input_shape=config['input_shape'],filter_shape=config['filter_shape'],poolsize=config['poolsize'],
283283
activation = conv_activation, use_fast = use_fast,dropout_factor=conv_layer_configs[i]['dropout_factor'])

src/run/run_DBN.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,17 @@ def runRBM(arg):
167167
########################
168168
if model_config['processes']['testing']:
169169
testing(dbn,data_spec)
170-
171170
##########################
172-
## Export Features ##
171+
# Export Features ##
173172
##########################
174173
if model_config['processes']['export_data']:
175-
exportFeatures(dbn,model_config,data_spec)
176-
export_path = model_config['export_path']+'.re'
177-
data_spec_testing = data_spec['testing']
178-
179-
out_function = getFunction(dbn)
180-
export_data(data_spec_testing,export_path,out_function,
181-
model_config['n_ins']);
174+
exportFeatures(dbn,model_config,data_spec)
182175

183176

184-
logger.info('Saving model to ' + str(model_config['output_file']) + ' ....')
185-
dbn.save(filename=model_config['output_file'], withfinal=True);
177+
logger.info('Saving model to ' + str(model_config['output_file']) + '....')
178+
dbn.save(filename=model_config['output_file'])
186179
logger.info('Saved model to ' + str(model_config['output_file']))
187180

188-
189-
190181
if __name__ == '__main__':
191182
import sys
192183
setLogger();

0 commit comments

Comments
 (0)