Skip to content

Instantly share code, notes, and snippets.

@gugarosa
Created May 30, 2019 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gugarosa/5f8e9d6e6af67cacb01cc1ed479be187 to your computer and use it in GitHub Desktop.
Save gugarosa/5f8e9d6e6af67cacb01cc1ed479be187 to your computer and use it in GitHub Desktop.
It supposes that you have a pre-loaded MNIST matrix and creates a mosaic of random samples.
% Check this repository to create your own MNIST Matlab's matrix
% https://github.com/daniel-e/mnist_octave/
% Loading MNIST matrix file
load('mnist.mat');
% Creating an empty array of 100 samples
A = zeros(28, 28, 1, 100, 'uint8');
% Looping through 100 random samples
for i = 1:100
% Gathering sample
I = trainX(i,:);
% Reshaping sample
I = reshape(I, [28, 28]).';
% Applying sample to array
A(:,:,1,i) = I;
end
% Plotting montage
montage(A, 'size', [10 10]);
% Writing output
print('mnist.eps','-deps2', '-r300');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment