To load an MNIST file in matlab, you can use the following code:
main.m582 chars19 lines
Assuming that the filename
variable contains the path to the MNIST image file, running the loadMNISTImages
function will return a numRows
x numCols
x numImages
matrix containing the MNIST images.
For example, to load the MNIST training images and display the first image, you can use the following code:
main.m77 chars3 lines
Note that the transpose is used when displaying the image because matlab reads in the image data in row-major order, while images are usually displayed in column-major order.
gistlibby LogSnag