-1
$\begingroup$

i am working on computer vision using deep learning. my training data contains (x,128) shape. i am passing the same to conv1d layer but facing issues

below is my model

input_dim = (128,)     
classifier = Sequential()

#convolutional layer 1
classifier.add(Convolution1D(32, kernel_size=3,input_shape = input_dim, activation = 'relu'))
classifier.add(MaxPooling1D(pool_size=2)) 
classifier.add(Dropout(.20))

#convolutional layer 2
classifier.add(Convolution1D(32, kernel_size=3, activation = 'relu'))
classifier.add(MaxPooling1D(pool_size=2))
classifier.add(Dropout(.20))

classifier.add(Convolution1D(32, kernel_size=3, activation = 'relu'))
classifier.add(MaxPooling1D(pool_size=2))
classifier.add(Dropout(.20))

#flatten 
classifier.add(Flatten())
classifier.add(Dense(output_dim =  128, activation='relu'))
$\endgroup$
  • $\begingroup$ Check your dims! $\endgroup$ – Aditya Jul 15 '19 at 8:13
  • $\begingroup$ Look at this answer, this is probably the same issue here: stackoverflow.com/a/49841111/9858126 $\endgroup$ – Sean Mirchi Jul 15 '19 at 8:21
  • $\begingroup$ @SeanMirchi i tried it. but still facing the same issue $\endgroup$ – Ashu Jul 15 '19 at 9:48
0
$\begingroup$

Conv1D requires (batch-size, steps, dim) inputs. Your input sounds like (batch-size, steps). I'm guessing you have 128 steps of some univariate series. If so your input_dim is (128, 1). Your input may need to be reshaped to add an extra dimension at the end to conform.

| improve this answer | |
$\endgroup$
-1
$\begingroup$

your shape should be (img_w, img_h, num_colour_channels)

| improve this answer | |
$\endgroup$
  • $\begingroup$ This is a 1D convolution. You are answering as if the input is a 2D image and performing a 2D convolution, which would require 4-dimensional tensors, not 3. $\endgroup$ – Sean Owen Nov 21 at 20:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.