title: How can i fix network input shape
body: <p>There is 1275 images which each image has dimension of (128,19,1). these images are divided into groups of five, so there is 255 (1275/5) samples which each sample has 5 images and final shape of data is (255, 5, 128, 19, 1). this data must be feed to a CONVLSTM2D network which its code is as below. the process of training is done completely but at start of evaluation process it gives below error. thanks if anyone can helps me to fix it.</p>
  <p>Error:</p>
  <p>IndexError: list index out of range</p>
  <p>File &quot;&quot;, line 1, in 
  runfile('D:/thesis/Paper 3/Feature Extraction/two_dimension_Feature_extraction/stft_feature/Training_set/P300/Afrah_convlstm2d.py', wdir='D:/thesis/Paper 3/Feature Extraction/two_dimension_Feature_extraction/stft_feature/Training_set/P300')</p>
  <p>File &quot;C:\Users\pouyaandish\AppData\Local\conda\conda\envs\kafieh\lib\site-packages\spyder_kernels\customize\spydercustomize.py&quot;, line 786, in runfile
  execfile(filename, namespace)</p>
  <p>File &quot;C:\Users\pouyaandish\AppData\Local\conda\conda\envs\kafieh\lib\site-packages\spyder_kernels\customize\spydercustomize.py&quot;, line 110, in execfile
  exec(compile(f.read(), filename, 'exec'), namespace)</p>
  <p>File &quot;D:/thesis/Paper 3/Feature Extraction/two_dimension_Feature_extraction/stft_feature/Training_set/P300/Afrah_convlstm2d.py&quot;, line 111, in 
  test_loss, test_acc = seq.evaluate(test_data)</p>
  <p>File &quot;C:\Users\pouyaandish\AppData\Local\conda\conda\envs\kafieh\lib\site-packages\keras\engine\training.py&quot;, line 1361, in evaluate
  callbacks=callbacks)</p>
  <p>File &quot;C:\Users\pouyaandish\AppData\Local\conda\conda\envs\kafieh\lib\site-packages\keras\engine\training_arrays.py&quot;, line 403, in test_loop
  if issparse(ins[i]) and not K.is_sparse(feed[i]):</p>
  <p>IndexError: list index out of range</p>
  <pre><code>#Importing libraries
  #-------------------------------------------------
  from PIL import Image
  from keras.models import Sequential
  from keras.layers import Flatten
  from keras.layers import Dense
  from keras.layers.convolutional_recurrent import ConvLSTM2D
  from keras.layers.normalization import BatchNormalization
  import numpy as np
  import os
  from matplotlib import pyplot as plt
  
  
  #Data Preprocessing
  #-----------------------------------------------------------------
  Data = np.zeros((255,5,128,19,1),dtype=np.uint8)
  
  image_folder = 'D:\\thesis\\Paper 3\\Feature Extraction\\two_dimension_Feature_extraction\\stft_feature\\Training_set\\P300'
  images = [img for img in os.listdir(image_folder) if img.endswith(&quot;.png&quot;)]
  
  for image in images:
      img = Image.open(image).convert('L')
      array = np.array(img)
      array = np.expand_dims(np.array(img), axis=2)
      for i in range(0, len(Data)):
          for j in range(0, 4):
              Data[i,j] = array
  
             
  
  labels = np.zeros((2,len(Data)), dtype=np.uint8)
  labels = np.transpose(labels)
  for i in range(0, len(Data) ):
      if i &lt;= 127:
          labels[i][0] = 1
      elif i &gt; 127 :
          labels[i][1] = 1            
              
  #Network Configuration
  #--------------------------------------------------------------------------------------------------------------------------
  seq = Sequential()
  seq.add(ConvLSTM2D(filters=40, kernel_size=(3, 3),
                     input_shape=(5, 128, 19, 1),
                     padding='same', return_sequences=True))
  seq.add(BatchNormalization())
  
  seq.add(ConvLSTM2D(filters=40, kernel_size=(3, 3),
                     padding='same', return_sequences=True))
  seq.add(BatchNormalization())
  
  seq.add(ConvLSTM2D(filters=40, kernel_size=(3, 3),
                     padding='same', return_sequences=True))
  seq.add(BatchNormalization())
  
  seq.add(ConvLSTM2D(filters=40, kernel_size=(3, 3),
                     padding='same', return_sequences=True))
  seq.add(BatchNormalization())
  
  seq.add(Flatten())
  seq.add(Dense(output_dim = 128, activation = 'relu'))
  seq.add(Dense(output_dim = 2, activation = 'relu'))
  seq.compile(loss='binary_crossentropy', optimizer='adadelta', metrics=['acc'])
  
  #Fit the Data on Model
  #--------------------------------------------------------------------------------------
  train_data_1 = Data[0:84]
  train_data_2 = Data[127:212]
  train_data = np.concatenate([train_data_1, train_data_2])
  label_train_1 = labels[0:84]
  label_train_2 = labels[127:212]
  label_train = np.concatenate([label_train_1, label_train_2])
  
  val_data_1 = Data[84:104]
  val_data_2 = Data[212:232]
  val_data = np.concatenate([val_data_1, val_data_2])
  label_val_1 = labels[84:104]
  label_val_2 = labels[212:232]
  label_val = np.concatenate([label_val_1, label_val_2])
  
  
  test_data_1 = Data[104:127]
  test_data_2 = Data[232:]
  test_data = np.concatenate([test_data_1, test_data_2])
  label_test_1 = labels[104:127]
  label_test_2 = labels[232:]
  label_test = np.concatenate([label_test_1, label_test_2])
  
  
  history = seq.fit(train_data,label_train, validation_data=( val_data, label_val), epochs = 2 , batch_size = 10)
  
  #Visualize the Result
  #---------------------------------------------------------------------------------------
  acc = history.history['acc']
  val_acc = history.history['val_acc']
  loss = history.history['loss']
  val_loss = history.history['val_loss']
  epochs = range(1, len(acc) + 1)
  plt.plot(epochs, acc, 'r', label='Training acc')
  plt.plot(epochs, val_acc, 'b', label='Validation acc')
  plt.title('Training and validation accuracy')
  plt.legend()
  plt.figure()
  plt.plot(epochs, loss, 'r', label='Training loss')
  plt.plot(epochs, val_loss, 'b', label='Validation loss')
  plt.title('Training and validation loss')
  plt.plot()
  plt.legend()
  plt.show()
  #Evaluate Model on test Data
  #----------------------------------------------------------------------------------------------
  test_loss, test_acc = seq.evaluate(test_data)
  print('test_acc:', test_acc)
  
  
  
  
  
       
  </code></pre>