digit recognition on MATLABDesign a fully convolutional neural network for digit classifi cation and train it on the MNIST dataset. MNIST provides images of the digits 0 to 9 of size 28  28, together...

1 answer below »
digit recognition on MATLABDesign a fully convolutional neural network for digit classifi cation and train it on the MNIST dataset. MNIST provides images of the digits 0 to 9 of size 28  28, together with the label for which digit is shown in a given image. Your fully convolutional neutral should be trained to produce the correct label for the center of the output of your last layer. MNIST provides training and validation data that you should use for training your neural network. Try out different architectures until you achieve at least 97% accuracy on the test set. Since MNIST is a relatively easy dataset, a few layers should be sufficient for this.Once you have trained your network, you can apply it on one of the evaluation images provided. Use non-maximum suppression and thresholding to obtain your digit predictions and write out the detected digits (no particular order required) on MATLAB's output line. Note that you will need to detect digits at multiple scales.


images provided/computer_generated.png images provided/computer_generated_rotated.png images provided/handwritten.png images provided/handwritten_rotated.png proj001.pdf 1 Project I: Digit Recognition The goal of this project is to develop a system for digit recognition in images. The system will be based on multi-scale processing with fully convolutional neural networks. Images for evaluation are provided on Canvas. 1.1 Mandatory Part Design a fully convolutional neural network for digit classification and train it on the MNIST dataset. MNIST provides images of the digits 0 to 9 of size 28 × 28, together with the label for which digit is shown in a given image. Your fully convolutional neutral should be trained to produce the correct label for the center of the output of your last layer. MNIST provides training and validation data that you should use for training your neural network. Try out different architectures until you achieve at least 97% accuracy on the test set. Since MNIST is a relatively easy dataset, a few layers should be sufficient for this. Once you have trained your network, you can apply it on one of the evaluation images provided on Canvas. Use non-maximum suppression and thresholding to obtain your digit predictions and write out the detected digits (no particular order required) on MATLAB’s output line. Note that you will need to detect digits at multiple scales. You can find instructions on how to use the MNIST dataset inside MATLAB here. What to include in the report. Your report should consist of the following: • A short abstract describing the problem behind the project and outlining your solution. • A “Method” section describing your approach: What network architecture are you using? How are you handling multi-scale processing? This section should be about one page long. • A “Experimental Evaluation” section describing the experiments you perform with your approach as well as the results of these experiments: – Describe the parameters you used for training, e.g., the learning rate, whether you used momentum, etc. – Plot training and validation loss over the number of epochs and explain how you decided when to stop the training process. – Measure the accuracy your classifier achieves on the test set of the MNIST dataset. – If you experimented with different neural network architectures, also include their results on the MNIST test set. – Visualize the evaluation images provided on Canvas and mark which digits were cor- rectly detected by your approach. Also mark false positive detections (e.g., using a different color). 1.2 Theoretical Part Answer the following questions in your report. Make sure to use your own words and justify your answers. http://yann.lecun.com/exdb/mnist/ http://yann.lecun.com/exdb/mnist/ http://daniel-e.github.io/2017-10-20-loading-mnist-handwritten-digits-with-octave-or-matlab/ (a) Fully convolutional neural networks vs. neural networks with fully connected layers. Explain the purpose of fully connected layers in convolutional neural networks. In which scenarios would you apply a fully convolutional neural network instead of a neural network with a fully connected layer? (b) Converting a fully connected to a fully convolutional layer. Explain how to convert a fully connected layer to a fully convolutional layer such that the fully convolutional layer provides the same functionality. (c) Scale-space construction. Explain how a scale space that allows the detection of ob- jects at multiple sizes is constructed: Which operations are involved? How is the scale space constructed using these operations? How can a scale space be constructed efficiently? 3
Answered Same DayApr 22, 2021

Answer To: digit recognition on MATLABDesign a fully convolutional neural network for digit classifi cation and...

Kshitij answered on May 01 2021
148 Votes
DIGIT/checkToolboxes.m
function ret = checkToolboxes(req)
% reqToolboxes = {'Neural Network Toolbox'};
% checkToolboxes(reqToolboxes)
info = ver;
s=size(info);
flg = zeros(size(req));
reqSize = size(req,2);
for i=1:s(2)
for j=1:reqSize
if( strcmpi(info(1,i).Name,req{1,j}) )
flg(1,j)=1;
end
end
end
ret = prod(flg);
DIGIT/computer_generated.png
DIGIT/computer_generated_rotated.png
DIGIT/datasets/load_dataset.m
function [XTrain, YTrain, XTest, YTest] = load_dataset( name, dir )
if( ~exist( 'dir', 'var' )
)
dir = [fileparts(mfilename('fullpath')),'/'];
end
if( dir(end) ~= '/' )
dir = [dir, '/'];
end
if( strcmpi( name, 'mnist' ) )
[XTrain, YTrain, XTest, YTest] = load_mnist( dir );
elseif( strcmpi( name, 'cifar10' ) )
[XTrain, YTrain, XTest, YTest] = load_cifar10( dir );
else
msg = sptrinf( 'Could not find: %s', name );
error(msg);
end
end
DIGIT/datasets/load_mnist.m
function [XTrain, YTrain, XTest, YTest] = load_mnist( dir )
url = 'http://yann.lecun.com/exdb/mnist/';
datasetfile = 'mnist.mat';
if( ~exist( 'dir', 'var' ) )
dir = [fileparts(mfilename('fullpath')),'/'];
end
if( dir(end) ~= '/' )
dir = [dir, '/'];
end
if( isfile( [dir, datasetfile] ) )
load( [dir, datasetfile] );
else
fprintf( 'Downloading mnist dataset. It may takes several minitus.\n' );
filename = 'train-images-idx3-ubyte';
websave([dir,filename,'.gz'], [url,filename, '.gz']);
gunzip([dir,filename, '.gz']);
XTrain = readMnistX([dir,filename]);
filename = [ dir, filename, '*' ];
delete(filename);

filename = 'train-labels-idx1-ubyte';
websave([dir,filename,'.gz'], [url,filename, '.gz']);
gunzip([dir,filename, '.gz']);
YTrain = readMnistY([dir,filename]);
filename = [ dir, filename, '*' ];
delete(filename);

filename = 't10k-images-idx3-ubyte';
websave([dir,filename,'.gz'], [url,filename, '.gz']);
gunzip([dir,filename, '.gz']);
XTest = readMnistX([dir,filename]);
filename = [ dir, filename, '*' ];
delete(filename);
filename = 't10k-labels-idx1-ubyte';
websave([dir,filename,'.gz'], [url,filename, '.gz']);
gunzip([dir,filename, '.gz']);
YTest = readMnistY([dir,filename]);
filename = [ dir, filename, '*' ];
delete(filename);

save([dir,datasetfile], 'XTrain', 'YTrain', 'XTest', 'YTest');
end

XTrain = double(XTrain) / 255.0;
YTrain = categorical(YTrain);
XTest = double(XTest) / 255.0;
YTest = categorical(YTest);
end
function X = readMnistX( filename )
fid = fopen(filename, 'r', 'b');
header = fread(fid, 1, 'int32');
if header ~= 2051
error('Invalid image file header');
end
count = fread(fid, 1, 'int32');
h = fread(fid, 1, 'int32');
w = fread(fid, 1, 'int32');

X = fread(fid, h*w*count, 'uint8');
X = reshape( X, [h,w,1,count] );
X = permute( X, [2,1,3,4] );

X = uint8(X);
fclose(fid);
end
function Y = readMnistY( filename )
fid = fopen(filename, 'r', 'b');
header = fread(fid, 1, 'int32');
if header ~= 2049
error('Invalid image file header');
end
count = fread(fid, 1, 'int32');

Y = fread(fid, count, 'uint8');
Y = reshape( Y, [count,1] );
Y = uint8(Y);

fclose(fid);
end
DIGIT/datasets/load_train1000.m
function [XTrain, YTrain, XTest, YTest] = load_train1000( name, dir )
if( ~exist( 'dir', 'var' ) )
dir = [fileparts(mfilename('fullpath')),'/'];
end
if( dir(end) ~= '/' )
dir = [dir, '/'];
end
if( strcmpi( name, 'mnist' ) )
[XTrain0, YTrain0, XTest, YTest] = load_mnist( dir );
[XTrain, YTrain] = extract(XTrain0, YTrain0, 10, 100);
elseif( strcmpi( name, 'cifar10' ) )
[XTrain0, YTrain0, XTest, YTest] = load_cifar10( dir );
[XTrain, YTrain] = extract(XTrain0, YTrain0, 10, 100);

else
msg = sptrinf( 'Could not find: %s', name );
error(msg);
end
end
function [X, Y] = extract(X0, Y0, nb_classes, nb_per_class)
s = size(X0);
X = X0(:,:,:,1:nb_classes*nb_per_class);
Y = Y0(1:nb_classes*nb_per_class,:);

k = 1;
n = zeros(nb_classes,1);
for i=1:size(X0,1)
c = int32(Y0(i,1));
if( n(c) < nb_classes )
X(:,:,:,k) = X0(:,:,:,i);
Y(k,:) = Y0(i,:);
n(c) = n(c) + 1;
k = k + 1;
if( k > nb_classes*nb_per_class )
break;
end
end
end
end
DIGIT/datasets/mnist.mat
XTrain:[4D uint8 array]
YTrain:[60000x1 uint8 array]
XTest:[4D uint8 array]
YTest:[10000x1 uint8 array]
DIGIT/Digit classification.docx
Digit classification and recognition using convolution neural network using MNISt dataset , We have trained the data using CNN with manipulation of training options to get desired training option. NOn-maximum suppression and thresholding is implementation to obtain digit predictions, MNIST dataset of 60,000 small square 28×28 pixel grayscale images of handwritten single digits between 0 and 9.
Method:-
Convolution neural network could considered as gradable NN which generally works in extraction of features of images by choosing options of convolving input with the help gaggle of kernel filters. After that the process of pooling of obtained feature is executed and filter resolution of next layer following, Now implementing convolution neural network algorithm.
Above given condition tells us about the lth...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here