I am trying to create a model for 1D convolution, but I cant seem to get the input shape correct. Here is what I have:
#this is actually shape (6826, 9000) but I am shortening it
train_dataset_x = np.array([[0, 1, 5, 1, 10], [0, 2, 4, 1, 3]])
#this is actually shape (6826, 1)
train_dataset_y = np.array([[0], [1]])
model.add(Conv1D(32, 11, padding='valid', activation='relu', strides=1, input_shape=( len(train_dataset_x[0]), train_dataset_x.shape[1]) ))
model.add(Conv1D(32, 3, padding='valid', activation='relu', strides=1) )
model.add(MaxPooling1D())
model.add(Conv1D(64, 3, padding='valid', activation='relu', strides=1) )
model.add(Conv1D(64, 3, padding='valid', activation='relu', strides=1) )
model.add(MaxPooling1D())
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
I get this error:
ValueError: Error when checking input: expected conv1d_1_input to have 3 dimensions, but got array with shape (6826, 9000)
Anyone have suggestions?
Input to keras.layers.Conv1D
should be 3-d with dimensions (nb_of_examples, timesteps, features)
. I assume that you have a sequence of length 6000
with 1 feature. In this case:
X = X.reshape((-1, 9000, 1))
Should do the job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With