I am using R programming language and using Keras API to build a functional 1D CNN.
I have a matrix of my dataset of the following shape rows*features (6000*1024).
The input layer is set using the following code:
input_layer = layer_input(shape = 1024, batch_shape = c(nrow(train_matrix),1024), dtype = 'float64')
and then I am building a 1d conv layer as follows:
conv1 = input_layer %>% layer_conv_1d(filters = 32, kernel_size = 50, strides = 10, input_shape = 1024, batch_input_shape = list(NULL, 1024) ,dtype = 'float64', activation = 'relu' )
But I get the following error:
Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: Input 0 is incompatible with layer conv1d: expected ndim=3, found ndim=2
I believe it is due to the fact that 1D cnn layer expects the input in the following form
Input shape: 3D tensor with shape: (batch_size, steps, input_dim)
I understand that I have to reshape my data as
(NULL, nrow(train_matrix), 1; as this has been suggested in various answer for the same issue arising for keras when used in Python.
If I am right,
- what values should I provide to input layer
- how should i reshape my training data?
- does that mean I have to reshape the test data as well?
also if my understanding is wrong what should be done otherwise ?