title: Create 5-dimension input shape to 3d-CNN in python
body: <p>I have a dataset of 15 class with 460 images all. I want to enter every 8 sequences of images at the same time to the same CNN structure. I use conv3d to do that, but I'm confusing with input shape, it returns error. 
  This is my model:</p>
  
  <pre><code>IMAGE_DIMS = (8, 460, 60, 60, 3)
  data = []
  labels = []
  
  # loading images...
  imagePaths = "dataset\\path"
  listing = os.listdir(imagePaths)
  
  for imagePath in listing:
  
      image_fold = os.listdir(imagePaths + "\\" + imagePath)
      for file in image_fold:
          im = (imagePaths + "\\" + imagePath + "\\" + file)
          image = cv2.imread(im)
          image = cv2.resize(image, (IMAGE_DIMS[2], IMAGE_DIMS[3]))
          image = img_to_array(image)
          data.append(image)
  
          label= imagePath.split(os.path.sep)[-1]
          labels.append(label)
  # scale the raw pixel intensities to the range [0, 1]
  data = np.array(data, dtype="float") / 255.0
  labels = np.array(labels)
  
  # binarize the labels
  lb = LabelBinarizer()
  labels = lb.fit_transform(labels)
  (trainX, testX, trainY, testY) =     train_test_split(data, labels, test_size=0.2, random_state=42)
  
  
  model = Sequential()
  sample= IMAGE_DIMS[0]
  frame=IMAGE_DIMS[1]
  height = IMAGE_DIMS[2]
  width=IMAGE_DIMS[3]
  channels=IMAGE_DIMS[4]
  classes=len(lb.classes_)
  
  inputShape = (sample, frame, height, width, channels)
  chanDim = -1
  
  if K.image_data_format() == "channels_first":
      inputShape = (sample, frame, channels, height, width)
      chanDim = 1
  
  model.add(Conv3D(32, (3, 3, 3),    padding="same", batch_input_shape=inputShape))
  model.add(Activation("relu"))
  model.add(BatchNormalization(axis=chanDim))
  model.add(MaxPooling3D(pool_size=(2, 2, 2),    padding="same", data_format="channels_last"))
  model.add(Dropout(0.25))
  
  model.add(Conv3D(64, (3, 3, 3), padding="same"))
  model.add(Activation("relu"))
  model.add(BatchNormalization(axis=chanDim))
  model.add(MaxPooling3D(pool_size=(2, 2, 2),    padding="same", data_format="channels_last"))
  model.add(Dropout(0.25))
  
  model.add(Flatten())
  model.add(Dense(128))
  model.add(Activation("relu"))
  model.add(BatchNormalization())
  model.add(Dropout(0.5))
  
  # softmax classifier
  model.add(Dense(classes))
  model.add(Activation("softmax"))
  model.summary()
  
  opt = Adam(lr=INIT_LR, decay=INIT_LR / EPOCHS)
    model.compile(loss="categorical_crossentropy",   optimizer= opt, metrics=["accuracy"])
  
  H = model.fit(trainX, trainY, batch_size=BS, epochs=EPOCHS, verbose=1,validation_data (testX,testY))
  </code></pre>
  
  <p>and this is my model summary:
  <a href="https://i.stack.imgur.com/lVDLn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lVDLn.png" alt="enter image description here"></a></p>
  
  <p>But I get the following error:</p>
  
  <pre><code>ValueError: Error when checking input: expected conv3d_1_input to have 5 dimensions, but got array with shape (368, 60, 60, 3)
  </code></pre>
  
  <p>How can I fix the error, can anyone please help me, I will be thankful for any help. I know the problem with the input shape, the compiler refer to the <code>model.fit</code> step. I thing trainX, testX, trainY, testY must be in 5-dim, but I cannot able to that.</p>