, MATLAB 4 , little-endian, MNIST big-endian. , , 0x00, 0x00, 0x08, 0x03, . MATLAB 0x03, 0x08, 0x00, 0x00. , 50855936, , .
, , , uint8. . , , - , . .
swapbytes, , . 1 uint32, , big-endian. , uint32, MATLAB double, , swapbytes.
, numRows x numCols , , . . .
clear all;
close all;
%
fid = fopen('t10k-images-idx3-ubyte', 'r');
%
%
%
%
A = fread(fid, 1, 'uint32');
magicNumber = swapbytes(uint32(A));
%
%
%
%
A = fread(fid, 1, 'uint32');
totalImages = swapbytes(uint32(A));
%
%
%
%
A = fread(fid, 1, 'uint32');
numRows = swapbytes(uint32(A));
%
%
%
%
A = fread(fid, 1, 'uint32');
numCols = swapbytes(uint32(A));
%
imageCellArray = cell(1, totalImages);
for k = 1 : totalImages
%
A = fread(fid, numRows*numCols, 'uint8');
%
%
%
imageCellArray{k} = reshape(uint8(A), numCols, numRows)';
end
%//Close the file
fclose(fid);
( numRows, numCols), ( magicNumber) ( totalImages), 2051, 28, 28 10000 . kth imageCellArray kth MNIST. imshow(imageCellArray{k});, k - 1 10000, .
, : double, , uint8, .
!