1
$\begingroup$

I am using a very simple model to classify a 224x224 RGB image.

For a test, I have labelled my images (2 labels "Green" or "Red", 2,000 images of each) based on colour of a single fixed pixel from upper part of image.

My simple model achieves very high accuracy and very low loss, until I add more "random" pixels to lower part of image.

Why is my model getting confused?

The model easily copes with:

enter image description here

But, when I add more pixels in lower part of image - it achieves only 50% accuracy and high loss:

enter image description here

These project is a bit facile but I am researching a simple image structure I can control.

def VerySimpleNet():
    model = keras.Sequential([
        keras.layers.Conv2D(16, kernel_size=3, activation=tf.nn.relu, input_shape=(224, 224, 3)),
        keras.layers.Dropout(0.4),
        keras.layers.Flatten(),
        keras.layers.Dense(3, activation=tf.nn.softmax)
    ])
return model

EDIT 1

Is it possible to add a bonus to Data Science questions to encourage more answers?

EDIT 2

I would really be interested if anybody was keen to have a more interactive chat(email,txt?) with me on this question.

$\endgroup$
1
$\begingroup$

I think the problem here is that you are trying to relate what you know about the input to what the model is trying to predict. I suggest trying to interpret why your model is giving certain outputs for images.

I came across SHAP a while back when reading about model interpretation. The image plot of SHAP should be able to narrow in on why your model is interpreting a label for a specific Image.

SHAP Image_plot

This should lead you to figure out why your model is making the prediction.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Hi Shivam, thanks for this suggestion, I will take a look at it. However, I think my input is not as complex. I label each image according to 1 pixel in the top part of image. For example pixel(25,100). This works very well, until I add random pixels in the lower half of the image. I don't understand why this should cause my very simple net an issue. $\endgroup$ – ManInMoon Oct 28 '19 at 9:16
  • 1
    $\begingroup$ Have you tried doing something else like adding a white background instead of black to see how that affected your output? The reason according to you why the label of your image is a particular label is because of a certain pixel. I suggest the explain-ability because this might lead you to some insight on why your model is making a particular decision. You may want to do some other experiment like changing the background to white to see what that results in. $\endgroup$ – Shivam Patel Oct 29 '19 at 18:33
  • $\begingroup$ I guess I could try making background white. Not sure why that would make a difference... $\endgroup$ – ManInMoon Oct 30 '19 at 11:42
1
$\begingroup$

One simple interpretation is that adding random noise of course can't help, and enough of it will sink your model performance. The model might eventually figure it out with enough training time, the right settings, etc, but it's having to sift through so much noise to find the signal you hid.

You have relatively few instances (2000) of relatively complex input (224x224x3 images). There are lots of opportunities for your 'random' additions to actually correlate somewhat with the label. What looks like a good feature to fit in the training set fails to generalize in your test set.

The last interpretation I'll offer is that you are using a convolutional layer here, which implies some degree of spatial invariance. What it learns about one 3x3x3 patch it learns equally for all 3x3x3 patches. But you intend it to learn something different about a particular single pixel. It really can't with a single convolutional layer with a small kernel. That is, your simple model is just too simple for this problem. Stacking more convolution + pooling layers might eventually get the spatial specialization that is required to solve your puzzle.

| improve this answer | |
$\endgroup$

Your Answer

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

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