Binary classification problem: I want to have One input layer(optional), One Conv1D layer then output layer of 1 neuron predicting either 1 or 0.
Here is my model:
x_train = np.expand_dims(x_train,axis=1)
x_valid = np.expand_dims(x_valid,axis=1)
#x_train = x_train.reshape(x_train.shape[0], 1, x_train.shape[1])
#x_valid = x_train.reshape(x_valid.shape[0], 1, x_train.shape[1])
model = Sequential()
#hidden layer
model.add(Convolution1D(filters = 1, kernel_size = (3),input_shape=(1,x_train.shape[2])))
#output layer
model.add(Flatten())
model.add(Dense(1, activation = 'softmax'))
sgd = SGD(lr=0.01, nesterov=True, decay=1e-6, momentum=0.9)
model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
print('model compiled successfully')
model.fit(x_train, y_train, nb_epoch = nb_epochs, validation_data=(x_valid,y_valid), batch_size=100)
Input shape: x_train.shape = (5,1,133906) which is (batch,steps,channels) respectively. Steps added through expand_dims. Actual size (5,133906) which is 5 samples of time series data of length 133906 sampled randomly sometimes at 2 ms and sometimes at 5 ms.
Error Message: ValueError: Negative dimension size caused by subtracting 3 from 1 for 'conv1d_1/convolution/Conv2D' (op: 'Conv2D') with input shapes: [?,1,1,133906], [1,3,133906,1].
How do I resolve this issue? What should the size of x_train and the input_size argument passed inside Conv1D be?