Adicione nova dimensão
xtrain = xtrain[..., np.newaxis]
xtrain = xtrain[..., None]
xtrain = xtrain.reshape(-1, 28, 28, 1)
xtrain = tf.reshape(xtrain, (-1, 28, 28, 1))
xtrain = np.expand_dims(xtrain, axis=-1)
coder