vishnu-sagubandi / Deep_NN

Deep Neural Networks implemented in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deep_NN

Deep Neural Network implemented in Python from scratch 😄
This currently supports:

  • Deep Neural Networks with fully connected layers and non-linearities.
  • Classification (Logistic and softmax) and Regression (L2).
  • Uses Batch Gradient Descent optimizer.

Modules

This actually contains four Modules:

Each of these above mentioned Modules contains a class whose name is same as module name

Example Code

Lets create a 3-layer Neural Network (two Hidden layers and a output layer)

from NN_model import *

3_layer_NN = NN_model(input_size=64, layers=[
                    Layer(units=32, activation="relu"),
                    Layer(units=16, activation="relu"),
                    Layer(units=5, activation="softmax")],
                    loss_type="categorical_crossentropy",
                    print_loss="True"
                    )

So this model takes in input of shape (64, m) where m is number of training examples. And each layer in the Neural Network belongs to Layer class which is implemented Layer module. Each layer takes two mandatory inputs units, activation where activation can take one of the types relu, sigmoid, softmax

And there are three types of losses: mse, binary_crossentropy, categorical_crossentropy and print_loss to print loss after each epoch.

Now lets fit the network,

3_layer_NN.fit(X, Y, epochs=1000, learning_rate=0.01)

So to predict and evaluate on some examples,

prediction = 3_layer_NN.predict(example)
3_layer_NN.evaluate(X_val, Y_val)

Finally, to view the details of network,

3_layer_NN.summary()

Note: No other libraries are used except numpy for vectorization and sys for printing the progress bar everything is implemented from scratch ✌️

About

Deep Neural Networks implemented in Python

License:MIT License


Languages

Language:Jupyter Notebook 57.0%Language:Python 43.0%