📚 The CoCalc Library - books, templates and other resources
License: OTHER
Credits: Forked from deep-learning-keras-tensorflow by Valerio Maggio
Introduction to Deep Learning
Deep learning allows computational models that are composed of multiple processing layers to learn representations of data with multiple levels of abstraction.
These methods have dramatically improved the state-of-the-art in speech recognition, visual object recognition, object detection and many other domains such as drug discovery and genomics.
Deep learning is one of the leading tools in data analysis these days and one of the most common frameworks for deep learning is Keras.
The Tutorial will provide an introduction to deep learning using keras
with practical code examples.
Artificial Neural Networks (ANN)
In machine learning and cognitive science, an artificial neural network (ANN) is a network inspired by biological neural networks which are used to estimate or approximate functions that can depend on a large number of inputs that are generally unknown
An ANN is built from nodes (neurons) stacked in layers between the feature vector and the target vector.
A node in a neural network is built from Weights and Activation function
An early version of ANN built from one node was called the Perceptron
The Perceptron is an algorithm for supervised learning of binary classifiers. functions that can decide whether an input (represented by a vector of numbers) belongs to one class or another.
Much like logistic regression, the weights in a neural net are being multiplied by the input vertor summed up and feeded into the activation function's input.
A Perceptron Network can be designed to have multiple layers, leading to the Multi-Layer Perceptron (aka MLP
)
The weights of each neuron are learned by gradient descent, where each neuron's error is derived with respect to it's weight.
Optimization is done for each layer with respect to the previous layer in a technique known as BackPropagation.
Building Neural Nets from scratch
Idea:
We will build the neural networks from first principles. We will create a very simple model and understand how it works. We will also be implementing backpropagation algorithm.
Please note that this code is not optimized and not to be used in production.
This is for instructive purpose - for us to understand how ANN works.
Libraries like theano
have highly optimized code.
(The following code is inspired from these terrific notebooks)
Start Building our ANN building blocks
Note: This process will eventually result in our own Neural Networks class
A look at the details
Function to generate a random number, given two numbers
Where will it be used?: When we initialize the neural networks, the weights have to be randomly assigned.
Define our activation function. Let's use sigmoid function
Derivative of our activation function.
Note: We need this when we run the backpropagation algorithm
Our neural networks class
When we first create a neural networks architecture, we need to know the number of inputs, number of hidden layers and number of outputs.
The weights have to be randomly initialized.
Activation Function
BackPropagation
Running the model on our dataset
Predicting on training dataset and measuring in-sample accuracy
Let's visualize and observe the results
Exercise:
Create Neural networks with 10 hidden nodes on the above code.
What's the impact on accuracy?
Exercise:
Train the neural networks by increasing the epochs.
What's the impact on accuracy?
Addendum
There is an additional notebook in the repo, i.e. [A simple implementation of ANN for MNIST](1.4 (Extra) A Simple Implementation of ANN for MNIST.ipynb) for a naive implementation of SGD and MLP applied on MNIST dataset.
This accompanies the online text http://neuralnetworksanddeeplearning.com/ . The book is highly recommended.