Professional Documents
Culture Documents
DeepLearning Lect5
DeepLearning Lect5
Lecture-4
Dr. Abdul Jaleel
Associate Professor
Handwritten digits classification
using neural network
Handwritten Digits
(Python Implementation)
313/313 [==============================]
- 0s 1ms/step - loss: 0.0813 - accuracy: 0.9779
[0.08133944123983383, 0.9779000282287598]
Epoch 1/10
1875/1875 [==============================] - 3s 2ms/step - loss: 0.2959 - accuracy: 0.9185
Epoch 2/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.1368 - accuracy: 0.9603
Epoch 3/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.0995 - accuracy: 0.9703
Epoch 4/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.0771 - accuracy: 0.9772
Epoch 5/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.0628 - accuracy: 0.9806
Epoch 6/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.0519 - accuracy: 0.9841
Epoch 7/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.0442 - accuracy: 0.9865
Epoch 8/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.0369 - accuracy: 0.9886
Epoch 9/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.0300 - accuracy: 0.9910
Epoch 10/10 1875/1875 [==============================] - 3s 2ms/step - loss: 0.0264 - accuracy: 0.9917
Out[59]:
<tensorflow.python.keras.callbacks.History at 0x1fe24629e80>
House Price Prediction
using Neural Networks
House Price Prediction using Neural Networks
House Price Prediction using Neural Networks
House Price Prediction using Neural Networks
House Price Prediction using Neural Networks
House Price Prediction using Neural Networks
House Price Prediction using Neural Networks
House Price Prediction using Neural Networks
Batch Gradient Descent
Batch Gradient Descent
We will use very simple home prices data set to implement batch and
stochastic gradient descent in python.
Batch gradient descent uses all training samples in forward pass to calculate cumulative error and
than we adjust weights using derivatives.
In stochastic GD, we randomly pick one training sample, perform forward pass, compute the error
and immediately adjust weights.
Data import for batch gradient descent in python
Data Preprocessing/Scaling:
Since our columns are on different scale it is important to perform scaling on
them
https://
towardsdatascience.com/get-into-shape-14637fe
1cd32
https://www.analyticsvidhya.com/blog/2021/04/
difference-between-fit-transform-fit_transform-
methods-in-scikit-learn-with-python-code
https://pandas.pydata.org/pandas-docs/version/0.23/
https://
pandas.pydata.org/pandas-docs/version/0.23/genera
ted/pandas.DataFrame.transform.html
Gradient descent allows you to find weights
(w1,w2,w3) and bias in following linear equation for
housing price prediction
Batch
Gradient
Descent
Stochastic Gradient Descent Implementation
Stochastic GD will use randomly picked single training sample to calculate error and using
this error we back propagate to adjust weights
Exercise
Implement mini batch gradient descent in python and plot cost vs epoch graph.
In stochastic we used one randomly picked training sample, In mini gradient descent you will use a batch
of samples in each iterations.
For example if you have total 50 training samples, you can take a batch of 10 samples, calculate
cumulative error for those 10 samples and then adjust weights.
In Batch we adjust weights after going through all samples but in mini batch we do after every m
samples (where m is batch size and it is 0 < m < n, where n is total number of samples