img = imageDatastore('HAM10000_images_part_1',...
'IncludeSubfolders',true,...
'LabelSource','foldernames');
figure
Images = length(img.Files);
perm = randperm(Images,40);
for i = 1:40
subplot(8,5,i);
imshow(img.Files{perm(i)});
end
imageSize = [64 64 3];
[imdsTrain,imdsTest] = splitEachLabel(img,0.7,'randomize');
datastore = augmentedImageDatastore(imageSize,imdsTrain);
layers = [
imageInputLayer(imageSize,'Name','input')
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,64,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
fullyConnectedLayer(7)
softmaxLayer
classificationLayer ];
options = trainingOptions('adam', ...
'MaxEpochs',3,...
'InitialLearnRate',0.01, ...
'Verbose',true, ...
'Plots','training-progress');
net = trainNetwork(datastore,layers,options);
YPred = classify(net,imdsTest);
YValidation = imdsTest.Labels;
accuracy = sum(YPred == YValidation)/numel(YValidation);