I'm creating a CNN model in keras to categorise data. There's 150 features (represented as columns), each of which has a label of 1 to 9. The issue is I'm confused about how to use this in Keras since there's uneaven numbers of features to labels, with the features being able to be shown with dimensions of 100, 150 and the labels with dimensions of 100,1. Help understanding how to properly train this data on a Keras model would be appreciated.

#Reshape data to add new dimension      
X_train = X_train.reshape((100, 150, 1)) 
Y_train = X_train.reshape((100, 1, 1)) 
model = Sequential() 
model.add(Conv1d(1, kernel_size=3, activation='relu', input_shape=(None, 1))) 
model.add(Dense(1)) model.add(Activation('sigmoid'))
model.compile(loss='categorical_hinge', optimizer='adam', metrics=['accuracy']) 
model.fit(x=X_train,y=Y_train, epochs=200, batch_size=20)

The current code works, but the Conv1d layer doesn't seem to change the accuracy of the model. How can I make the model get above the 20% accuracy it currently reaches and utilise the Conv1d layer?


1 Answer 1


try to add more conv layers, and also play a bit with hyperparameters to improve accuracy. Currently, the learning rate is being used as default, try to tweak it from 0.01 to 0.0001.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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