Deep Neural Network from scratch on Image Classification - Dogs or Cats? is the project that we finished after the 5th week of studying Machine Learning.
Dogs vs. Cats dataset provided by Microsoft Research contains 25,000 images of dogs and cats with the labels
- 1 = dog
- 0 = cat
-
Building a basic deep neural network from scratch to classify dogs and cats images
-
Tunning the hyperparameters of the model in order to achieve high accuracy. This project explores the applicability of deep neural network by tunning these hyperparameters:
- Learning rate
- Number of hidden layers
- Number of nodes in each hiden layers
- Number of iterations
In this notebook, we implemented all the functions required to build a deep neural network.
Notation:
- Superscript
denotes a quantity associated with the
layer.
- Superscript
denotes a quantity associated with the
example.
- Lowerscript
denotes the
entry of a vector.
The initialization for a deeper L-layer neural network is more complicated because there are many more weight matrices and bias vectors. When completing the initialize_params
, we made sure that our dimensions match between each layer. Given is the number of units in layer
. Thus for example if the size of our input
is
(with
examples) then:
Shape of W | Shape of b | Activation | Shape of Activation | |
---|---|---|---|---|
Layer 1 | ||||
Layer 2 | ||||
Layer L-1 | ||||
Layer L |
Remember that when we compute in python, it carries out broadcasting. For example, if:
The linear forward module (vectorized over all the examples) computes the following equations:
where . And the activation functions:
Note that denotes elementwise multiplication.
The three outputs are computed using the input
.Here are the formulas we need:
We achieved the Accuracy score of 65.2% which is better than the Accuracy score of Logistic Regression Model in sklearn (57.6%). Our hyperparameters are:
- Learning rate =
0.001
- Number of hidden layers =
5
- Number of nodes in each hidden layers =
[32,64,128,256,512]
- Number of iterations =
2500