I\'m currently working on a case study for which I need to work on the MNIST database.
The files in this site are said to be in IDX file format. I tried to take a look at th
I tried the above, using:
data <- readBin(to.read, integer(), size = 1, n = 784, endian="big")
but ended up with both positive and negative integers in the image. Consequently, when plotted, using:
plot(as.cimg(data))
I get a grey background with the character in pixels that are darker or lighter than the background.
I then used: (see [1]https://tensorflow.rstudio.com/tfestimators/articles/examples/mnist.html)
data <- readBin(to.read, what = "raw", n = 784, endian="big")
conv <- as.integer(data)
mm <- matrix(conv, 28, 28)
Now I have only positive values (0 to 255), and the plot gives a proper white character on a black background. Which is what I wanted.