%%
filename = 'mnist';
digitDatasetPath = fullfile(matlabroot,'toolbox','nnet','nndemos', ...
'nndatasets','DigitDataset');
imds = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%%
labelCount = countEachLabel(imds);
%%
Y = categorical(imds.Labels);
for i = 1:sum(labelCount.Count)
img = im2double(readimage(imds,i));
imgs(:,i) = img(😃;
end
X = tsne(imgs',Algorithm="barneshut",Perplexity=300);
%%
figure;gscatter(X(:,1),X(:,2),Y)
xlabel(' x 1 x_1 x1', 'FontSize',14, 'Interpreter','latex')
ylabel(' x 2 x_2 x2', 'FontSize',14, 'Interpreter','latex')
box off