# 1D CNN time series classiifcation : ValueError: Shapes (10, 10, 8) and (10, 8) are incompatible

I'm working on a time series classification using ASHRAE RP-1043 chiller dataset which has 65 columns and more than 3000 rows for each chiller fault and normal condition. And I have used 1D CNN and training results are 99.35% which is pretty good and tested with data that didn't involve in training data set. and my output categorical feature is one hot encoded Following is the code i used for it and works pretty good.And the train data shape is as following

# make it 3d  input
X_train = scaled_x_train.reshape(-1,1,65)
X_train.shape,y_train.shape


((81600, 1, 65), (81600, 8))

  def create_nn_model():
model = Sequential()
return model

model = create_nn_model()
model.fit(X_train, y_train, epochs=100,batch_size=10,verbose=1)


But here when i change the kernel size to 3 and max pooling size to 2 and also the input shape as in the following i get the following error.

# make it multi steps compatible input
X_train = scaled_x_train.reshape(-1,10,65)
y_train = y_train.reshape(-1,10,8)
X_train.shape,y_train.shape

>((8160, 10, 65), (8160, 10, 8))

def create_nn_model():
model = Sequential()
return model

model = create_nn_model()
model.fit(X_train, y_train, epochs=100,batch_size=10,verbose=1)


ValueError: Shapes (10, 10, 8) and (10, 8) are incompatible.

Model: "sequential_81"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
conv1d_141 (Conv1D)          (None, 8, 64)             12544
_________________________________________________________________
conv1d_142 (Conv1D)          (None, 6, 64)             12352
_________________________________________________________________
dropout_61 (Dropout)         (None, 6, 64)             0
_________________________________________________________________
max_pooling1d_61 (MaxPooling (None, 3, 64)             0
_________________________________________________________________
flatten_58 (Flatten)         (None, 192)               0
_________________________________________________________________
module_wrapper_91 (ModuleWra (None, 8)                 1544
=================================================================
Total params: 26,440
Trainable params: 26,440
Non-trainable params: 0
`

May be i may not have very much clear idea as to what kernel and filters. Or is it something to be done with the my 3d input shape? Can please anyone advice me on setting up the structure of data for the model's input layer (both X and Y)

• @Kaveh Hi sorry i was trying many configurations and error message was fixed now. I have devided both my x and y to use 10 time steps since i want to use more than one kernel size in convolutional layer. The second dimension you asked for is time step. It should be 10. Jul 10 at 12:24
• (8160,10,65) this is the shape of the input data(X_train) but i have to reshape y_train also to shape as (8160,10,8) otherwise i will get error message when fitting the model saying both x and y arrays should be in same size. So I had to reshape the y_train also. and also i have one hot encoded my y (y_train & y_test) my categorical output variable. Can you please suggest me how to avoid this error. In LSTM there is a option called return_sequences set to true but here there is not Jul 10 at 12:35
• @Kaveh Can you please direct me with an example based on the code here? as to how can i adopt a timedistributed wrapper? Jul 10 at 13:49
• I couldn't find an example where TimeDistributed layer has been used in Conv1D other than in Conv2D Jul 10 at 19:57
• Wrap the CNN layer with TimeDistributed See here. Jul 11 at 12:55