You are currently viewing Interesting Facts about Deep Learning, Convolutional Neural Networks using Python

Interesting Facts about Deep Learning, Convolutional Neural Networks using Python

Ques1: When there is a need to reshape dataset ?

Ans1:  When we want to apply convolutions and we don’t have all the information about which pixels are near to each other for feature detection. By reshaping the dataset it is feasible to associate group of pixels to detect important features.

Reshape function in python for ASL(American Sign Language Dataset)

ASL(American Sign Language)
x_train.shape -> (274555, 784)
x_train.reshape(-1,28,28,1) -> (274555, 28, 28, 1)

As a convenience, we can pass the reshape method a -1 for any dimension we wish to remain the same.

Ques2: What is a need of Batch Normalization between hidden layers?

Ans2: Batch Normalization technique stabilizes the learning process and dramatically reduces the number of training epochs required to train deep neural networks. Python syntax for batch normalization –

from tensorflow.keras.layers import (
Dense,
Conv2D,
MaxPool2D,
Flatten,
Dropout,
BatchNormalization,
)
model = Sequential()
model.add(BatchNormalization())

Ques3: How we can check overfitting by looking at model training results?

Ans: If the difference between training loss and validation loss is more i.e. training loss is .1045(approx) and validation loss is .89432(approx) then this is the case of overfitting. To handle overfitting one way is to increase dataset size by creating more data with the help of rotation, translation and scaling.

to increase data, Python Keras Library comes with ImageDataGenerator class, it can be used as,

from tensorflow.keras.preprocessing.image import ImageDataGenerator
datagen = ImageDataGenerator(
rotation_range=10, # randomly rotate images in the range (degrees, 0 to 180)
zoom_range=0.1, # Randomly zoom image
width_shift_range=0.1, # randomly shift images horizontally (fraction of total width)
height_shift_range=0.1, # randomly shift images vertically (fraction of total height)
horizontal_flip=True, # randomly flip images horizontally
vertical_flip=False, # Don't randomly flip images vertically
)

Ques4: How to clean GPU memory?

Ans: The code to clean GPU memory is :

import IPython
app = IPython.Application.instance()
app.kernel.do_shutdown(True)

This Post Has 2 Comments

  1. CBD oil for sale

    There’s certainly a great deal to learn about this topic.
    I really like all the points you’ve made.

  2. Thanks for finally writing about > Interesting Facts about
    Deep Learning, Convolutional Neural Networks using Python –
    . < Loved it!

Leave a Reply