title: Negative dimension size caused by subtracting 2 from 1 for 'conv2d_2/convolution' (op: 'Conv2D') with input shapes: [?,174,1,40], [2,2,40,16]
body: <pre><code>%store -r x_train 
  %store -r x_test 
  %store -r y_train 
  %store -r y_test 
  %store -r yy 
  %store -r le
  import numpy as np
  import keras
  from keras.models import Sequential
  from keras.layers import Dense, Dropout, Activation, Flatten
  from keras.layers import Convolution2D, Conv2D, MaxPooling2D,  
  GlobalAveragePooling2D
  from keras.optimizers import Adam
  from keras.utils import np_utils
  from sklearn import metric
  num_rows = 40
  num_columns = 174
  num_channels = 1
  x_train = x_train.reshape(x_train.shape[0],num_rows , num_columns, 
  num_channels)
  x_test = x_test.reshape(x_test.shape[0], num_rows, 
  num_columns,num_channels )
  
  num_labels = yy.shape[1]
  filter_size = 2
  model = Sequential()
  
  model.add(Conv2D(filters=16, kernel_size=2, 
  activation='relu',input_shape=(40,174,1)))
  model.add(MaxPooling2D(pool_size=2))
  model.add(Dropout(0.2))
  
  model.add(Conv2D(filters=32, kernel_size=2, activation='relu'))
  model.add(MaxPooling2D(pool_size=2))
  model.add(Dropout(0.2))
  
  model.add(Conv2D(filters=64, kernel_size=2, activation='relu'))
  model.add(MaxPooling2D(pool_size=2))
  model.add(Dropout(0.2))
  
  model.add(Conv2D(filters=128, kernel_size=2, activation='relu'))
  model.add(MaxPooling2D(pool_size=2))
  model.add(Dropout(0.2))
  model.add(GlobalAveragePooling2D())
  
  model.add(Dense(num_labels, activation='softmax'))
  </code></pre>
  
  <p>this is the full code. 
  when i am trying to create a model of CNN i stuck with this error. </p>
  
  <pre><code>InvalidArgumentError                      Traceback (most recent call 
  last)
  ~/arshin/home/arshin/envs/aiml/lib/python3.6/site- 
   packages/tensorflow/python/framework/ops.py in _create_c_op(graph, 
   node_def, inputs, control_inputs)
   1566   try:
   -&gt; 1567     c_op = c_api.TF_FinishOperation(op_desc)
    1568   except errors.InvalidArgumentError as e:
  
   InvalidArgumentError: Negative dimension size caused by subtracting 2 
   from 1 for 'conv2d_1/convolution' (op: 'Conv2D') with input shapes: 
   [?,174,1,40], [2,2,40,16].
  </code></pre>
  
  <p>code contain no error. why this happened....... is this because of the tensorflow version or something.. I tried many things but i can't correct the error. what's the problem in this code..</p>