Deep learning with Python: The human brain imitation.
Published: 2019-06-07 13:05:26

<p>The main idea behind <a href="https://builtin.com/artificial-intelligence/deep-learning">deep learning</a> is that artificial intelligence should draw inspiration from the brain. This perspective gave rise to the "neural network” terminology. The brain contains billions of neurons with tens of thousands of connections between them. Deep learning algorithms resemble the brain in many conditions, as both the brain and deep learning models involve a vast number of computation units (neurons) that are not extraordinarily intelligent in isolation but become intelligent when they interact with each other.</p>

<blockquote>
<p><em>I think people need to understand that deep learning is making a lot of things, behind-the-scenes, much better. Deep learning is already working in Google search, and in image search; it allows you to image search a term like “hug.”— Geoffrey Hinton</em></p>
</blockquote>

<p>&nbsp;</p>

<h2 id="811b">Neurons</h2>

<p>The basic building block for neural networks is artificial neurons, which imitate human brain neurons. These are simple, powerful computational units that have weighted input signals and produce an output signal using an activation function. These neurons are spread across several layers in the neural network.</p>

<p>Below is the image of how a neuron is imitated in a neural network. The neuron takes in a input and has a particular weight with which they are connected with other neurons. Using the Activation function the nonlinearities are removed and are put into particular regions where the output is estimated.&nbsp;</p>

![](https://thepracticaldev.s3.amazonaws.com/i/eq87ieske9v3vlfbjwzl.png)


<h2 id="49b3">How Do Artificial Neural Network&nbsp;Works?</h2>

<p>Deep learning consists of artificial neural networks that are modeled on similar networks present in the human brain. As data travels through this artificial mesh, each layer processes an aspect of the data, filters outliers, spots familiar entities, and produces the final output.</p>

![](https://builtin.com/sites/default/files/styles/ckeditor_optimize/public/inline-images/artificial-neural-network-deep-learning.jpeg)


<p><strong>Input layer&nbsp;:&nbsp;</strong>This layer consists of the neurons that do nothing than receiving the inputs and pass it on to the other layers. The number of layers in the input layer should be equal to the attributes or features in the dataset.</p>

<p><strong>Output Layer:</strong>The output layer is the predicted feature, it basically depends on the type of model you’re building.</p>

<p><strong>Hidden Layer:&nbsp;</strong>In between input and output layer there will be hidden layers based on the type of model. Hidden layers contain vast number of neurons. The neurons in the hidden layer apply transformations to the inputs and before passing them. As the network is trained the weights get updated, to be more predictive.</p>

<p>&nbsp;</p>

<h3 id="998f"><strong>Neuron Weights</strong></h3>

<p>Weights refer to the strength or amplitude of a connection between two neurons, if you are familiar with linear regression you can compare weights on inputs like coefficients we use in a regression equation.Weights are often initialized to small random values, such as values in the range 0 to 1.</p>

<p>&nbsp;</p>

<h3 id="5fad"><strong>Feedforward Deep&nbsp;Networks</strong></h3>

<p>Feedforward supervised neural networks were among the first and most successful learning algorithms. They are also called deep networks, multi-layer Perceptron (MLP), or simply neural networks and the vanilla architecture with a single hidden layer is illustrated. Each Neuron is associated with another neuron with some weight,</p>

<p>The network processes the input upward&nbsp;<strong>activating</strong>&nbsp;neurons as it goes to finally produce an output value. This is called a forward pass on the network.</p>

<p>The image below depicts how data passes&nbsp;through the series of layers.</p>

![](https://builtin.com/sites/default/files/styles/ckeditor_optimize/public/inline-images/Feedforward%20Deep%20Networks.png)

<h3 id="ac23"><strong>Activation Function</strong></h3>

<p>An activation function is a mapping of summed weighted input to the output of the neuron. It is called an activation/ transfer function because it governs the inception at which the neuron is activated and the strength of the output signal.</p>

<p>Mathematically,</p>


<p>There are several activation functions that are used for different use cases. The most commonly used activation functions are relu, tanh, softmax. The cheat sheet for activation functions is given below.</p>

![](https://thepracticaldev.s3.amazonaws.com/i/s2ycjew4t8c75gbxsrd2.png)


<h3 id="b530"><strong>BackPropagation</strong></h3>

<p>The predicted value of the network is compared to the expected output, and an error is calculated using a function. This error is then propagated back within the whole network, one layer at a time, and the weights are updated according to the value that they contributed to the error. This clever bit of math is called the <strong>backpropagation algorithm</strong>. The process is repeated for all of the examples in your training data.&nbsp;One round of updating the network for the entire training dataset is called an epoch.&nbsp;A network may be trained for tens, hundreds or many thousands of epochs.</p>

![](https://thepracticaldev.s3.amazonaws.com/i/bzt9s46ltnjvv446oige.png)

<h3 id="ee5e"><strong>Cost Function and Gradient&nbsp;Descent</strong></h3>

<p>The cost function is the measure of “how good” a neural network did for its given training input and the expected output. It also may depend on attributes such as weights and biases.</p>

<p>A cost function is single-valued, not a vector because it rates how well the neural network performed as a whole. Using the gradient descent optimization algorithm, the weights are updated incrementally after each epoch.</p>


Read the rest with <a href="https://builtin.com/data-science/deep-learning-python">deep learning Python examples and libraries here</a>.