clear close all load('ArabicHC.mat'); imageAugmenter = imageDataAugmenter( ... 'RandRotation',[-1.5,1.5] ,... 'RandXTranslation',[-3,3] ,... 'RandYTranslation',[-3,3] ,... 'RandXScale',[0.9,1.1],... 'RandYScale',[0.9,1.1]); imageSize = [32,32,1]; auimds = augmentedImageSource(imageSize,XTrain,TTrain,'DataAugmentation',imageAugmenter); %% Define the Network Layers layers = [ imageInputLayer([32 32 1],'Normalization','none','Name','input') convolution2dLayer(5,64,'Name','conv1') batchNormalizationLayer('Name','BN1') reluLayer('Name','relu1') % 28x28 convolution2dLayer(5,128,'Name','conv2') batchNormalizationLayer('Name','BN2') reluLayer('Name','relu2') % 24x24 convolution2dLayer(5,176,'Name','conv3') batchNormalizationLayer('Name','BN3') reluLayer('Name','relu3') % 20x20 maxPooling2dLayer(2,'Stride',2,'Name','max1') % 10x10 convolution2dLayer(5,208,'Name','conv4') batchNormalizationLayer('Name','BN4') reluLayer('Name','relu4') % 6x6 convolution2dLayer(5,240,'Name','conv5') batchNormalizationLayer('Name','BN5') reluLayer('Name','relu5') % 2x2 maxPooling2dLayer(2,'Stride',2,'Name','max2') fullyConnectedLayer(28,'Name','fc') softmaxLayer('Name','softmax') classificationLayer('Name','classOutput')]; %% Specify the Training Options options = trainingOptions('sgdm','LearnRateSchedule','piecewise',... 'MiniBatchSize',192,'LearnRateDropFactor',0.998,... 'LearnRateDropPeriod',2,... 'MaxEpochs',3200, ... 'InitialLearnRate',0.002462,... 'Shuffle','every-epoch'); convnet = trainNetwork(auimds,layers,options); YTest = classify(convnet,XTest); accuracy = sum(YTest == TTest)/numel(TTest); Error=(1-accuracy)*100