%MNIST The MNIST database as a PRTools dataset
%
% [TRAIN,TEST] = MNIST
% TRAIN_TEST = MNIST
%
% The MNIST database as supplied by Yann LeCun in PRTools format. It
% contains of 10 classes of handwritten digits of 28 x 28 pixels.
% The trainset has 60000 digits and the testset 1000.
%
% SEE ALSO PRTools Guide, Original Website
% PRTOOLS, DATASETS, SHOW
function varargout = mnist
varargout = cell(1,nargout);
[varargout{:}] = pr_loadmatfile;
if isempty(varargout{1})
a = pr_getdata(['http://prtools.tudelft.nl/prdatafiles/MNIST_train.zip'],42,'mnist_train','',1);
b = pr_getdata(['http://prtools.tudelft.nl/prdatafiles/MNIST_test.zip'],[],'mnist_test','',0);
% Note that these are datafiles
user.desc = ['This is the trainset of MNIST.'];
user.link = ['http://yann.lecun.com/exdb/mnist/'];
a = setuser(a,user)*datasetm; % convert to dataset
user.desc = ['This is the testset of MNIST.'];
user.link = ['http://yann.lecun.com/exdb/mnist/'];
b = setuser(b,user)*datasetm; % convert to dataset
a = setname(a,'MNIST');
b = setname(b,'MNIST');
% save separate and combined files
[varargout{:}] = pr_savematfile(a,b);
end