I have build a model to classify numbers and characters on Images. I trained it on the Chars74K dataset and in training it has 80% validation accuracy. I just use the number and uppercase characters of the computer generated dataset. But when I feed it some example images it doesn´t classify a single one of them right. this is my model:

model = tf.keras.models.Sequential([
tf.keras.layers.Dense(512, input_shape=(4096,), name="first_hidden", activation=tf.nn.sigmoid),
tf.keras.layers.Dense(36, name="output", activation=tf.nn.sigmoid)
model.compile(optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"])
model.fit(xTrain, yTrain, epochs=20, batch_size=200, validation_split=0.2, callbacks=[tensorboard])

I have run 155 different combinations of models (1, 2 or 3 hidden layers with each 32, 64, 128, 256 or 512 Neurons) and this was the best one.

Could someone of you please help me?

  • 1
    $\begingroup$ Maybe the images were from test dataset had some sort of similarity with the training dataset ( which it obvious has ). Your images might be too distinct for the model on which it has been trained. Factors which result in this distinctness could the image background, color, fonts, or even dimensions of the image. $\endgroup$ – user234584 Mar 9 at 13:44
  • $\begingroup$ I think @ShubhamPanchal is on the right track. Discrepancies between how the data appear in training vs testing, or testing vs production can cause all sorts of "phantom" effects to appear. One neural network researcher thought they had a NN that could determine if a person was a criminal or not just from facial portraits. The problem was that the criminals' portraits were all from official identification cards and the non-criminals were professional headshots so the network was actually just a smile detector. $\endgroup$ – Sycorax Mar 9 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.