clear close all load('My_UFPR.mat') trainimage=trainimages; trainlabel=trainlabels; load('LPALIC_Latin.mat') trainlabel(trainlabel=="I")=categorical(1); % in Brazil the class I and 1 has the same font trainlabel=removecats(trainlabel); trainimages=cat(4,trainimage,trainimages); trainlabels=[trainlabel;trainlabels,]; %% Define the Network Layers layers = [ imageInputLayer([28 28 1],'Normalization','none','Name','input') convolution2dLayer(5,64,'Name','conv1') batchNormalizationLayer('Name','BN1') reluLayer('Name','relu1') % 24x24 convolution2dLayer(5,128,'Name','conv2') batchNormalizationLayer('Name','BN2') reluLayer('Name','relu2') % 20x20 maxPooling2dLayer(2,'Stride',2,'Name','max1') % 10x10 convolution2dLayer(5,176,'Name','conv3') batchNormalizationLayer('Name','BN3') reluLayer('Name','relu3') % 6x6 convolution2dLayer(5,208,'Name','conv4') batchNormalizationLayer('Name','BN4') reluLayer('Name','relu4') % 2x2 maxPooling2dLayer(2,'Stride',2,'Name','max2') fullyConnectedLayer(34,'Name','fc') softmaxLayer('Name','softmax') classificationLayer('Name','classOutput')]; %% Specify the Training Options options = trainingOptions('sgdm','LearnRateSchedule','piecewise',... 'MiniBatchSize',120,'LearnRateDropFactor',0.7,... 'LearnRateDropPeriod',2,... 'MaxEpochs',20, ... 'InitialLearnRate',0.01,... 'Shuffle','every-epoch'); convnet = trainNetwork(trainimages,trainlabels,layers,options); % load('UFPR_result_LPALIC_train_test_20397.mat') YTest = classify(convnet,testimages); accuracy = sum(YTest == testlabels)/numel(testlabels); Error=(1-accuracy)*100