imds = imageDatastore('filelocation','FileExtensions','.mat','LabelSource','none','ReadFcn',@matRead);
labels = load('filelocationLabels');
importLabels = labels.Labels;
imds.Labels = importLabels(1:length(dir('filelocationLabels'))-2);
[imds2,imds1] = splitEachLabel(imds,500,'randomized');
    image3dInputLayer([16 8 800 1],"Name","image3dinput","Normalization","none")
    convolution3dLayer([3 3 3],32,"Name","conv3d")
    convolution3dLayer([3 3 3],64,"Name","conv3d_1","Padding",[1 1 1;1 1 1])
    maxPooling3dLayer([3 3 3],"Name","maxpool3d_1")
    convolution3dLayer([3 3 3],64,"Name","conv3d_2","Padding",[1 1 1;1 1 1])
    maxPooling3dLayer([3 3 3],"Name","maxpool3d_2")
    fullyConnectedLayer(512,"Name","fc_1")
    reluLayer("Name","relu_1")
    fullyConnectedLayer(256,"Name","fc_2")
    reluLayer("Name","relu_2")
    fullyConnectedLayer(128,"Name","fc_3")
    reluLayer("Name","relu_3")
    fullyConnectedLayer(10,"Name","fc_4")
    softmaxLayer("Name","softmax")
    classificationLayer("Name","classoutput")];
options = trainingOptions('adam', ...
    'InitialLearnRate',0.001, ...
    'ExecutionEnvironment','gpu', ...
    'ValidationData',imds2, ...
    'ValidationFrequency',50, ...
    'GradientThreshold',2, ...
    'VerboseFrequency',1000,...
    'Shuffle','every-epoch', ...
    'Plots','training-progress');
HandyNet = trainNetwork(imds,layers,options);
function data = matRead(filename)