keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.71k stars 19.43k forks source link

Compile function for 1D convolutional neural networks #2 #3612

Closed nalamotse1 closed 7 years ago

nalamotse1 commented 8 years ago

Hello guys, I am working on a time series data, fitting it into a 1D convolutional neural network but I seem to not find the right compile model. My net is configured in the following way: model = Sequential()

model.add(Convolution1D(21, 1, 7,activation='relu',init='uniform')) model.add(MaxPooling1D(pool_length=2)) model.add(Dropout(0.2))

model.add(Flatten()) model.add(Dense(7,1, activation='sigmoid'))

nb_timesteps = 7 # 2 (previous) + 1 (current) nb_sequences = input_var.shape[0] - nb_timesteps #8-3=5

input_3D = np.array([input_var[i:i+nb_timesteps] for i in range(nb_sequences)]) model.compile(loss='mean_squared_error', optimizer='adadelta') model.fit(input_3D, targetValue, batch_size=450, nb_epoch=10, validation_split=0.05,show_accuracy=True,verbose = 0)

And I do get this kind of error: model.fit(input_3D, targetValue, batch_size=450, nb_epoch=10, validation_split=0.05,show_accuracy=True,verbose = 0) File "build/bdist.linux-x86_64/egg/keras/models.py", line 490, in fit File "build/bdist.linux-x86_64/egg/keras/models.py", line 211, in fit File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1-py2.7.egg/theano/compile/function_module.py", line 871, in _call storage_map=getattr(self.fn, 'storage_map', None)) File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1-py2.7.egg/theano/gof/link.py", line 314, in raise_with_op reraise(exc_type, exc_value, exc_trace) File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1-py2.7.egg/theano/compile/function_module.py", line 859, in call outputs = self.fn()

nouiz commented 8 years ago

This is a partial error message. It more the instant part. Can you give the full error?

Le 28 août 2016 16:11, "nalamotse1" notifications@github.com a écrit :

Hello guys, I am working on a time series data, fitting it into a 1D convolutional neural network but I seem to not find the right compile model. My net is configured in the following way: model = Sequential()

model.add(Convolution1D(21, 1, 7,activation='relu',init='uniform')) model.add(MaxPooling1D(pool_length=2)) model.add(Dropout(0.2))

model.add(Flatten()) model.add(Dense(7,1, activation='sigmoid'))

nb_timesteps = 7 # 2 (previous) + 1 (current) nb_sequences = input_var.shape[0] - nb_timesteps #8 https://github.com/fchollet/keras/issues/8-3=5

input_3D = np.array([input_var[i:i+nb_timesteps] for i in range(nb_sequences)]) model.compile(loss='mean_squared_error', optimizer='adadelta') model.fit(input_3D, targetValue, batch_size=450, nb_epoch=10, validation_split=0.05,show_accuracy=True,verbose = 0)

And I do get this kind of error: model.fit(input_3D, targetValue, batch_size=450, nb_epoch=10, validation_split=0.05,show_accuracy=True,verbose = 0) File "build/bdist.linux-x86_64/egg/keras/models.py", line 490, in fit File "build/bdist.linux-x86_64/egg/keras/models.py", line 211, in fit File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1- py2.7.egg/theano/compile/function_module.py", line 871, in _call storage_map=getattr(self.fn, 'storage_map', None)) File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1-py2.7.egg/theano/gof/link.py", line 314, in raise_with_op reraise(exc_type, exc_value, exc_trace) File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1- py2.7.egg/theano/compile/function_module.py", line 859, in call outputs = self.fn()

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fchollet/keras/issues/3612, or mute the thread https://github.com/notifications/unsubscribe-auth/AALC-4Phy2jog6pEkbLzugoXmHWz3Yk8ks5qketWgaJpZM4JvAYL .

nalamotse1 commented 8 years ago

Okay Nouiz. here is the full error:

model.fit(input_3D, targetValue, batch_size=450, nb_epoch=10, validation_split=0.05,show_accuracy=True,verbose = 0) File "build/bdist.linux-x86_64/egg/keras/models.py", line 490, in fit File "build/bdist.linux-x86_64/egg/keras/models.py", line 211, in _fit File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1-py2.7.egg/theano/compile/function_module.py", line 871, in call storage_map=getattr(self.fn, 'storage_map', None)) File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1-py2.7.egg/theano/gof/link.py", line 314, in raise_with_op reraise(exc_type, exc_value, exc_trace) File "/usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1-py2.7.egg/theano/compile/function_module.py", line 859, in call outputs = self.fn() ValueError: the filter stack size (21) and image stack size (7) differ Apply node that caused the error: ConvOp{('imshp', (None, None, None)),('kshp', (None, None)),('nkern', None),('bsize', None),('dx', 1),('dy', 1),('out_mode', 'valid'),('unroll_batch', None),('unroll_kern', None),('unroll_patch', True),('imshp_logical', (None, None, None)),('kshp_logical', (None, None)),('kshp_logical_top_aligned', True)}(InplaceDimShuffle{0,2,1,3}.0, <TensorType(float64, 4D)>) Toposort index: 41 Inputs types: [TensorType(float64, (False, False, False, True)), TensorType(float64, 4D)] Inputs shapes: [(450, 7, 7, 1), (1, 21, 7, 1)] Inputs strides: [(392, 8, 56, 8), (1176, 56, 8, 8)] Inputs values: ['not shown', 'not shown'] Outputs clients: [[Elemwise{add,no_inplace}(ConvOp{('imshp', (None, None, None)),('kshp', (None, None)),('nkern', None),('bsize', None),('dx', 1),('dy', 1),('out_mode', 'valid'),('unroll_batch', None),('unroll_kern', None),('unroll_patch', True),('imshp_logical', (None, None, None)),('kshp_logical', (None, None)),('kshp_logical_top_aligned', True)}.0, InplaceDimShuffle{x,0,x,x}.0), Elemwise{Composite{(i0 * (Abs(i1) + i2 + i3))}}[(0, 2)](TensorConstant{%281, 1, 1, 1%29 of 0.5}, Elemwise{add,no_inplace}.0, ConvOp{%28'imshp', %28None, None, None%29%29,%28'kshp', %28None, None%29%29,%28'nkern', None%29,%28'bsize', None%29,%28'dx', 1%29,%28'dy', 1%29,%28'out_mode',),('unroll_batch', None),('unroll_kern', None),('unroll_patch', True),('imshp_logical', (None, None, None)),('kshp_logical', (None, None)),('kshp_logical_top_aligned', True)}.0, InplaceDimShuffle{x,0,x,x}.0)]]

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer): File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 43, in get_input return self.previous.get_output(train=train) File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 331, in get_output X = self.get_input(train) File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 43, in get_input return self.previous.get_output(train=train) File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 250, in get_output X = self.get_input(train) File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 43, in get_input return self.previous.get_output(train=train) File "build/bdist.linux-x86_64/egg/keras/layers/convolutional.py", line 211, in get_output X = self.get_input(train) File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 43, in get_input return self.previous.get_output(train=train) File "build/bdist.linux-x86_64/egg/keras/layers/convolutional.py", line 72, in get_output conv_out = T.nnet.conv.conv2d(X, self.W, border_mode=border_mode, subsample=self.subsample)

HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.