ReadingTestingDataSet.m 865 B

12345678910111213141516171819202122232425262728293031323334353637
  1. clear all
  2. close all
  3. clc
  4. imgSz=28; % square image pixel size
  5. N=1e4; % Number of pictures to label
  6. %% Reading Binary Training Images
  7. fileOffset = 16; % bytes of file offset
  8. fileID = fopen('../Data/t10k-images.idx3-ubyte');
  9. Yset = fread(fileID,imgSz^2*N+fileOffset,'uint8');
  10. Yset = Yset(fileOffset+1:end);
  11. fclose(fileID);
  12. %% Reading Binary Training Labels
  13. fileOffsetL = 8; % bytes of file offset
  14. fileIDL = fopen('../Data/t10k-labels.idx1-ubyte');
  15. Yl = fread(fileIDL,N+fileOffsetL,'uint8');
  16. Yl = Yl(fileOffsetL+1:end);
  17. fclose(fileIDL);
  18. %% Building 3D matrix with N images
  19. Ymat = Vector2PictureMatrix(imgSz, N, Yset);
  20. %% Showing images
  21. figure()
  22. suptitle('Ordered chosen pictures from the Training Data Set')
  23. for kk=1:10
  24. subplot(2, 5, kk)
  25. ind=find(Yl==kk-1,1,'first');
  26. imshow(255-Ymat(:,:,ind),[0 255])
  27. xlabel(int2str(Yl(ind)));
  28. end