function [X_TRAIN Y_TRAIN X_TEST Y_TEST] = Load_MNIST(num_array, labels, n_train, n_test)

load('mnist_all.mat');

X_TEST  = [];
Y_TEST  = [];
X_TRAIN = [];
Y_TRAIN = [];
for ii = 1:length(num_array)
    eval(['X_tmp = test' ,num2str(num_array(ii)),''';']);
    X_TEST = [X_TEST X_tmp(:,1:n_test)];
    Y_TEST = [Y_TEST labels(ii)*ones(1,n_test)];
    
    eval(['X_tmp = train' ,num2str(num_array(ii)),''';']);
    X_TRAIN = [X_TRAIN X_tmp(:,1:n_train)];
    Y_TRAIN = [Y_TRAIN labels(ii)*ones(1,n_train)];
end
X_TEST = cast(X_TEST, 'double')/255.0;
X_TRAIN = cast(X_TRAIN, 'double')/255.0;
