In this blog post, we will be building a feed forward neural network and convolutional neural network from scratch on “Fruit 360” dataset using PyTorch

FEED FORWARD NEURAL NETWORK

A feed-forward neural network is an artificial neural network wherein connections between the nodes do not form a cycle. As such, it is different from its descendant: recurrent neural networks. The feed-forward neural network was the first and simplest type of artificial neural network devised.

FFN are of two types —

  1. Single layer feed forward network
  2. Multi layer feed forward network

Image for post

Single layer FFN consists of single layer of output nodes, inputs are fed directly to the output via a series of weights. Sum of product of weights and inputs is calculated at each node and if it is greater than threshold, the neuron fires and takes the activation value.

Multi-layer FFN consists of hidden layers between input and output layers. Hidden nodes do not directly send outputs to the external environment. FFN overcomes the limitation of single layer FFN i.e. they can handle non-linearly separable learning tasks.

CONVOLUTIONAL NEURAL NETWORK

The name “convolutional neural network” indicates that the network employs a mathematical operation called convolution. Convolution is a specialized kind of linear operation. Convolutional networks are simply neural networks that use convolution in place of general matrix multiplication in at least one of their layers.

Image for post

Some terms that are related to CNN and are important to understand the working of a CNN are —

  1. Channel
  2. Kernel
  3. Filter
  4. Padding
  5. Stride
  6. ReLu
  7. Pooling

LETS START WITH OUR MODELS

Basic steps involved in building a neural network are —

  1. import and analyze the dataset
  2. define training and validation set
  3. build the model
  4. train the model
  5. perform hyper-parameter tuning
  6. evaluate the model

The Dataset which we will be using

Fruit 360 is a dataset of images containing fruits and vegetables. The dataset contains 90483 images of 1131 different fruits and vegetables.

Dataset properties

Total number of images: 90483.

Training set size: 67692 images (one fruit or vegetable per image).

Test set size: 22688 images (one fruit or vegetable per image).

Multi-fruits set size: 103 images (more than one fruit (or fruit class) per image)

Number of classes: 131 (fruits and vegetables).

Image size: 100x100 pixels.

Filename format: image_index_100.jpg (e.g. 32_100.jpg) or r_image_index_100.jpg (e.g. r_32_100.jpg) or r2_image_index_100.jpg or r3_image_index_100.jpg. “r” stands for rotated fruit. “r2” means that the fruit was rotated around the 3rd axis. “100” comes from image size (100x100 pixels).

Different varieties of the same fruit (apple for instance) are stored as belonging to different classes.

#neural-networks #pytorch #convolutional-network #kaggle #deep-learning

FNN and CNN using Pytorch
16.35 GEEK