0

I have tried the procedure given here:

https://www.mathworks.com/help/deeplearning/ug/data-sets-for-deep-learning.html

after downloading the .gz files from http://yann.lecun.com/exdb/mnist/

but it simply does not work, I get the following error:

Number of images in the dataset: 2055376946 ...
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.

Error in processImagesMNIST (line 31)
X = reshape(X,numCols,numRows,numImages);

Error in main (line 10)
XTrain = processImagesMNIST(filenameImagesTrain);

Any ideas? This is very annoying for such a simple dataset. Also it is unfortunate that it is provided in this strange binary format 'ubyte'. Any other links with a more convenient format for the MNIST original dataset. (But ideally I would like to load it from this ubyte format)

This is something that is supposed to work "out of the box" that s why its particularly annoying; one does not want to code a specific script to read this binary data. Especially for such a well-known dataset.

1 Answer 1

1

I found out myself: use the uncompressed files! (without .gz extension) ... so Matlab s code is obviously wrong (they feed the compressed .gz files on their example) this is very strange... i.e. this code is wrong:

oldpath = addpath(fullfile(matlabroot,'examples','nnet','main'));
filenameImagesTrain = 'train-images-idx3-ubyte.gz';
filenameLabelsTrain = 'train-labels-idx1-ubyte.gz';
filenameImagesTest = 't10k-images-idx3-ubyte.gz';
filenameLabelsTest = 't10k-labels-idx1-ubyte.gz';

XTrain = processImagesMNIST(filenameImagesTrain);
YTrain = processLabelsMNIST(filenameLabelsTrain);
XTest = processImagesMNIST(filenameImagesTest);
YTest = processLabelsMNIST(filenameLabelsTest);

the filenames must instead be those of the uncompressed files

1
  • At the bottom of the MATLAB documentation page, there’s a box with 5 stars you can use to give feedback: give it a low score, then in the text box that comes up explain what you found. This way they can fix their documentation. I’ve found them very receptive of these notifications. Commented Aug 1, 2021 at 14:04

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