Q:

Keras model.evaluate() failing

I have created a little ConvNet which look likes this: 
model = Sequential()
optimizer = Adam()

model.add(Lambda(lambda x: x / 127.5 - 1., input_shape=(28, 28, 1)))
model.add(Convolution2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(NUM_CLASSES, activation='softmax'))

model.compile(optimizer=optimizer, loss=keras.losses.categorical_crossentropy, metrics=['accuracy'])

I am training it with data of shape 
X_train.shape = (48000, 28, 28, 1)
X_val.shape = (12000, 28, 28, 1)

And it works well. 
However, I would now like to test the model using keras.evaluate() function:
score = trained_model.evaluate(X_test, y_test, batch_size=128)
# X_test.shape = (10000, 28, 28, 1)
# y_test.shape (10000,)

Which result in the following error: 
ValueError: Error when checking target: expected dense_2 to have shape (10,) but got array with shape (1,)

I don't quite understand this error, given that I use the same shape for my training, validation and test set. 
Would you mind explaining what my error is, and how to fix it? 
Many thanks!
Edit: Output of trained_model.summary()
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
lambda_1 (Lambda)            (None, 28, 28, 1)         0
_________________________________________________________________
conv2d_1 (Conv2D)            (None, 26, 26, 64)        640
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 13, 13, 64)        0
_________________________________________________________________
dropout_1 (Dropout)          (None, 13, 13, 64)        0
_________________________________________________________________
flatten_1 (Flatten)          (None, 10816)             0
_________________________________________________________________
dense_1 (Dense)              (None, 128)               1384576
_________________________________________________________________
dropout_2 (Dropout)          (None, 128)               0
_________________________________________________________________
dense_2 (Dense)              (None, 10)                1290
=================================================================
Total params: 1,386,506
Trainable params: 1,386,506
Non-trainable params: 0

Solution given in the comment  
I forgot to one hot encore my y_train, y_val and y_test data. 
Solved with: 
from keras.utils.np_utils import to_categorical
y_train = to_categorical(y_train)

A:

The error says that the targets (the y's) are expected to have a shape that is one-hot encoded, each sample with 10 elements. You show that y_test has shape (10000,), which is not one-hot encoded.
You can do this with:
y_test = kera.utils.np_utils.to_categorical(y_test)

