Step by Step Procedure That How I Resolve Given Task Pytorh

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Step by step procedure that how I resolve given task

1. first read about pytorch numpy


2. read about mnist images data set
3. understand given model
2. setup pytorch use anaconda as framework
3. setup libtorch
4. one by one convert all layers of given model in cpp code
5. connected all the layers and form model
6. use tensor flow / tensor
7. convert given model into torchscript to run with c++ extension
8.

Okay, let's begin.


What is a neural network?
Since hundreds of years, philosophers and scientists have been interested in the
human brain. The brain, you must know, is extremely efficient in what it does -
allowing humans to think with unprecedented complexity and sheer flexibility.

Some of those philosophers and scientists have also been interested in finding out
how to make an artificial brain - that is, use a machine to mimic the functionality of
the brain.

 the filter.
 The stride tells us how the kernel jumps over the input image. If the stride is
1, it slides pixel by pixel. If it's two, it jumps one pixel. It jumps two with a
stride of 3, and so on.
 The padding tells us what happens when the kernels/filters don't fit, for
example because the input image has a width and height that do not match
with the combination of kernel size and stride.
 Depending on the backend you're using Keras with, the channels (each image
has image channels, e.g. 3 channels with Red-Green-Blue or RGB) are in
the first dimension or the last. Hence, the data format represents whether it's
a channels first or channels last approach. With recent versions of Keras, which
support TensorFlow only, this is no longer a concern.
 If you're using dilated convolutions, the dilation rate can be specified as well.
 The activation function to which the linear output of the Conv2D layer is fed
to make it nonlinear can be specified too.
 A bias value can be added to each layer in order to scale the learnt function
vertically. This possibly improves training results. It can be configured here,
especially if you don't want to use biases. By default, it's enabled.
 The initializer for the kernels, the biases can be configured too, as well
as regularizers and constraints.

Introduction

A convolutional neural network (CNN), is a network architecture for


deep learning which learns directly from data. CNNs are particularly
useful for finding patterns in images to recognize objects. They can
i -> Size of input , K-> Size of kernel, S-> Stride, p->Padding

Pooling

Pooling in convolutional neural networks is a technique for


generalizing features extracted by convolutional filters and helping
the network recognize features independent of their location in the
image.

Flatten

Flattening is used to convert all the resultant 2-Dimensional arrays


from pooled feature maps into a single long continuous linear
vector. The flattened matrix is fed as input to the fully connected
layer to classify the image.
Dropout

Another typical characteristic of CNNs is a Dropout layer. The


Dropout layer is a mask that nullifies the contribution of some
neurons towards the next layer and leaves unmodified all others.

Activation Function

An Activation Function decides whether a neuron should be


activated or not. This means that it will decide whether the neuron’s
input to the network is important or not in the process of prediction.
There are several commonly used activation functions such as the
ReLU, Softmax, tanH, and the Sigmoid functions. Each of these
functions has a specific usage.
Sigmoid — For a binary classification in the CNN model

tanH - The tanh function is very similar to the sigmoid function.


The only difference is that it is symmetric around the origin. The
range of values, in this case, is from -1 to 1.

Softmax- It is used in multinomial logistic regression and is often


used as the last activation function of a neural network to normalize
the output of a network to a probability distribution over predicted
output classes.

RelU- the main advantage of using the ReLU function over other
activation functions is that it does not activate all the neurons at the
same time.

Layers used to build CNN

Convolutional neural networks are distinguished from other neural


networks by their superior performance with image, speech, or
audio signal inputs. They have three main types of layers, which are:

 Convolutional layer

 Pooling layer

 Fully-connected (FC) layer

Convolutional layer
This layer is the first layer that is used to extract the various features
from the input images. In this layer, We use a filter or Kernel
method to extract features from the input image.

Pooling layer

The primary aim of this layer is to decrease the size of the convolved
feature map to reduce computational costs. This is performed by
decreasing the connections between layers and independently
operating on each feature map. Depending upon the method used,
there are several types of Pooling operations. We have Max pooling
and average pooling.

Fully-connected layer

The Fully Connected (FC) layer consists of the weights and biases
along with the neurons and is used to connect the neurons between
two different layers. These layers are usually placed before the
output layer and form the last few layers of a CNN Architecture.

Refrences

https://pytorch.org/docs/stable/index.html === pytorch documentation

https://medium.com/@draj0718/convolutional-neural-networks-cnn-architectures-explained-
716fb197b243

You might also like