% This program uses the weights obtained from the training process with %TestMultiClass.m to classify slightly corrupted images. clear all close all clc TestMultiClass; % call TestMultiClass.m to retrieve weights W1 and W2. % The iInput set consists of five 5x5 pixel squares. %0: white pixel; 1: black pixel. X = zeros(5, 5, 5); X(:, :, 1) = [0 0 1 1 0; 0 0 1 1 0; 0 1 0 1 0; 0 0 0 1 0; 0 1 1 1 0]; X(:, :, 2) = [1 1 1 1 0; 0 0 0 0 1; 0 1 1 1 0; 1 0 0 0 1; 1 1 1 1 1]; X(:, :, 3) = [1 1 1 1 0; 0 0 0 0 1; 0 1 1 1 0; 1 0 0 0 1; 1 1 1 1 0]; X(:, :, 4) = [0 1 1 1 0; 0 1 0 0 0; 0 1 1 1 0; 0 0 0 1 0; 0 1 1 1 0]; X(:, :, 5) = [0 1 1 1 1; 0 1 0 0 0; 0 1 1 1 0; 0 0 0 1 0; 1 1 1 1 0]; % Inference: N = size(X,3); y = zeros(N,5); %5 because of the one-hot encoding method. for k = 1:N x = reshape(X(:, :, k), 25, 1); v1 = W1*x; y1 = Sigmoid(v1); v = W2*y1; y(k,:) = Softmax(v); end disp('Results:'); disp(' [network_output]:'); disp(y) %% Showing images: for i = 1:N compareImages(X(:,:,i), y(i,:)); end