TF02: Fashion MNIST - Neural Network model

 


Objective :
Develop a neural network model capable of recognizing clothing items using the Fashion MNIST dataset.

Fashion MNIST dataset :  has 28X28 pixel size images, it contains 70,000 images of shirts, pants, boots, etc.
Training and Test data: Fashion MNIST Dataset
Input: An image of Fashion


Output: Able to tell the item with probability.

Code link :

The solution we got from Deep neural network solution is as below 


  • Now we solve the see the same Fashion MNSIT classification problem using CNN (Convolution neural network).
  • Convolution Neural networks provide better accuracy than Deep neural networks.
  • Let's understand the Convolution Neural network. 
  • There are two main concepts of CNN
    • Convolutions 
    • Max Pooling
Convolutions : 


The idea of convolution is to create another grid of numbers called kernel or filter which will scan over original pixel values to generate convoluted image.

For Corner values,  'o' values will be padded  and computed


Final Convoluted image 

Max Pooling:

Max pooling is the process of reducing the size of the input image by summarizing regions.
There are two things in max pooling:
1. Grid
2. Stride

Select the grid and pick the greatest value

stride  --> slide by two pixels


Complete the scan for an entire picture then you will get a reduced-size image.

CNN codelink:

The output of this CNN model has better accuracy than the Dense neural network

model = tf.keras.Sequential([
    tf.keras.layers.Conv2D(32, (3,3), padding='same', activation=tf.nn.relu,
                           input_shape=(28, 28, 1)),
    tf.keras.layers.MaxPooling2D((2, 2), strides=2),
    tf.keras.layers.Conv2D(64, (3,3), padding='same', activation=tf.nn.relu),
    tf.keras.layers.MaxPooling2D((2, 2), strides=2),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(128, activation=tf.nn.relu),
    tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])

Please learn the following terms

  • Flattening: The process of converting a 2d image into 1d vector
  • ReLU: An activation function that allows a model to solve nonlinear problems
  • Softmax: A function that provides probabilities for each possible output class
  • Classification: A machine learning model used for distinguishing among two or more output categories
  • CNNs: Convolutional neural network. That is, a network which has at least one convolutional layer. A typical CNN also includes other types of layers, such as pooling layers and dense layers.
  • Convolution: The process of applying a kernel (filter) to an image
  • Kernel / filter: A matrix which is smaller than the input, used to transform the input into chunks
  • Padding: Adding pixels of some value, usually 0, around the input image
  • Pooling The process of reducing the size of an image through downsampling.There are several types of pooling layers. For example, average pooling converts many values into a single value by taking the average. However, maxpooling is the most common.
  • Maxpooling: A pooling process in which many values are converted into a single value by taking the maximum value from among them.
  • Stride: the number of pixels to slide the kernel (filter) across the image.
  • Downsampling: The act of reducing the size of an image

References







Comments

Popular posts from this blog

Devops overview

EdgeAI

GIS Dashboard for RailwayLine Safety