3
$\begingroup$

In the MNIST dataset, are the images on white or black background? I seem to have encounter both type of images by googling around. Does the background color has any effects on the performance of a neural network in a recognition task?

$\endgroup$

1 Answer 1

2
$\begingroup$

The home of the MNIST dataset is at http://yann.lecun.com/exdb/mnist/

The page says: "Pixel values are 0 to 255. 0 means background (white), 255 means foreground (black)."

What matters to a neural net are the pixel values 0 (background) and 255 (foreground), though you can assign different colors to these pixel values when plotting the images.

A neural net trained on images with 0 as background and 255 as foreground will not be able to recognize images with inverted colors. You'd have a train a neural net on both types of images if you want it to work on both.

$\endgroup$
6
  • $\begingroup$ strangely, I have obtained better results by using black as background. Im not sure what is going on.. $\endgroup$
    – dnth
    Aug 12, 2015 at 9:14
  • $\begingroup$ What pixel value have you assigned to black? 0 or 255? If 0 is black, then the neural net should work fine. $\endgroup$
    – stmax
    Aug 12, 2015 at 9:55
  • $\begingroup$ yep zero is black. $\endgroup$
    – dnth
    Aug 12, 2015 at 10:35
  • 1
    $\begingroup$ That's why the neural net works.. it doesn't know about colors, only about pixel values (0 - 255). As long as the background is 0 and the digits are 255 it will work, no matter what color you assign to foreground/background. $\endgroup$
    – stmax
    Aug 12, 2015 at 11:23
  • 1
    $\begingroup$ @JackSimpson yes, the network's architecture can stay the same. Just train it with your own data. $\endgroup$
    – stmax
    Feb 21, 2017 at 13:57

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.