1010from collections import OrderedDict
1111from io_modules .file_reader import read_dataset
1212from utils .plotter import plot
13+ from utils .utils import parse_activation
1314
1415import logging
1516logger = logging .getLogger (__name__ )
@@ -157,8 +158,7 @@ def plot_layer_output(self,plot_spec,plot_path,max_images=10):
157158class CNN (CNNBase ):
158159 """ Instantiation of Convolution neural network ... """
159160 def __init__ (self , numpy_rng , theano_rng , batch_size , n_outs ,conv_layer_configs , hidden_layer_configs ,
160- use_fast = False ,conv_activation = T .nnet .sigmoid ,hidden_activation = T .nnet .sigmoid ,
161- l1_reg = None ,l2_reg = None ,max_col_norm = None ):
161+ use_fast = False ,hidden_activation = T .nnet .sigmoid ,l1_reg = None ,l2_reg = None ,max_col_norm = None ):
162162
163163 super (CNN , self ).__init__ (conv_layer_configs , hidden_layer_configs ,l1_reg ,l2_reg ,max_col_norm )
164164 if not theano_rng :
@@ -171,7 +171,7 @@ def __init__(self, numpy_rng, theano_rng, batch_size, n_outs,conv_layer_configs,
171171 input = self .layers [- 1 ].output #output of previous layer
172172
173173 config = conv_layer_configs [i ]
174-
174+ conv_activation = parse_activation ( config [ 'activation' ])
175175 conv_layer = ConvLayer (numpy_rng = numpy_rng , input = input ,input_shape = config ['input_shape' ],
176176 filter_shape = config ['filter_shape' ],poolsize = config ['poolsize' ],
177177 activation = conv_activation , use_fast = use_fast )
@@ -255,8 +255,8 @@ def save_mlp2dict(self,withfinal=True,max_layer_num=-1):
255255class DropoutCNN (CNNBase ):
256256 """ Instantiation of Convolution neural network ... """
257257 def __init__ (self , numpy_rng , theano_rng , batch_size , n_outs ,conv_layer_configs , hidden_layer_configs ,
258- use_fast = False ,conv_activation = T .nnet .sigmoid ,hidden_activation = T . nnet . sigmoid ,
259- l1_reg = None , l2_reg = None , max_col_norm = None ,input_dropout_factor = 0.0 ):
258+ use_fast = False ,hidden_activation = T .nnet .sigmoid ,l1_reg = None , l2_reg = None ,
259+ max_col_norm = None ,input_dropout_factor = 0.0 ):
260260
261261 super (DropoutCNN , self ).__init__ (conv_layer_configs ,hidden_layer_configs ,l1_reg ,l2_reg ,max_col_norm )
262262 self .input_dropout_factor = input_dropout_factor ;
@@ -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-
280+ activation = conv_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' ])
0 commit comments