Artificial Neural Networks (ANNs) make up an integral part of the Deep Learning process. They are inspired by the neurological structure of the human brain. According to AILabPage, ANNs are “complex computer code written with the number of simple, highly interconnected processing elements which is inspired by human biological brain structure for simulating human brain working & processing data (Information) models.”

**Deep Learning focuses on five core Neural Networks, including:**

- Multi-Layer Perceptron
- Radial Basis Network
- Recurrent Neural Networks
- Generative Adversarial Networks
- Convolutional Neural Networks.

**Neural Network: Architecture**

Neural Networks are complex structures made of artificial neurons that can take in multiple inputs to produce a single output. This is the primary job of a Neural Network – to transform input into a meaningful output. Usually, a Neural Network consists of an input and output layer with one or multiple hidden layers within.

In a Neural Network, all the neurons influence each other, and hence, they are all connected. The network can acknowledge and observe every aspect of the dataset at hand and how the different parts of data may or may not relate to each other. This is how Neural Networks are capable of finding extremely complex patterns in vast volumes of data.

**Read: **Machine Learning vs Neural Networks

**In a Neural Network, the flow of information occurs in two ways –**

**Feedforward Networks:**In this model, the signals only travel in one direction, towards the output layer. Feedforward Networks have an input layer and a single output layer with zero or multiple hidden layers. They are widely used in pattern recognition.**Feedback Networks:**In this model, the recurrent or interactive networks use their internal state (memory) to process the sequence of inputs. In them, signals can travel in both directions through the loops (hidden layer/s) in the network. They are typically used in time-series and sequential tasks.

**Neural Network: Components**

**Input Layers, Neurons, and Weights** –

In the picture given above, the outermost yellow layer is the input layer. A neuron is the basic unit of a neural network. They receive input from an external source or other nodes. Each node is connected with another node from the next layer, and each such connection has a particular weight. Weights are assigned to a neuron based on its relative importance against other inputs.

When all the node values from the yellow layer are multiplied (along with their weight) and summarized, it generates a value for the first hidden layer. Based on the summarized value, the blue layer has a predefined “activation” function that determines whether or not this node will be “activated” and how “active” it will be.

Let’s understand this using a simple everyday task – making tea. In the tea making process, the ingredients used to make tea (water, tea leaves, milk, sugar, and spices) are the “neurons” since they make up the starting points of the process. The amount of each ingredient represents the “weight.” Once you put in the tea leaves in the water and add the sugar, spices, and milk in the pan, all the ingredients will mix and transform into another state. This transformation process represents the “activation function.”

**Learn about: **Deep Learning vs Neural Networks

**Hidden Layers and Output Layer** –

The layer or layers hidden between the input and output layer is known as the hidden layer. It is called the hidden layer since it is always hidden from the external world. The main computation of a Neural Network takes place in the hidden layers. So, the hidden layer takes all the inputs from the input layer and performs the necessary calculation to generate a result. This result is then forwarded to the output layer so that the user can view the result of the computation.

In our tea-making example, when we mix all the ingredients, the formulation changes its state and color on heating. The ingredients represent the hidden layers. Here heating represents the activation process that finally delivers the result – tea.

**Neural Network: Algorithms**

In a Neural Network, the learning (or training) process is initiated by dividing the data into three different sets:

**Training dataset –**This dataset allows the Neural Network to understand the weights between nodes.**Validation dataset –**This dataset is used for fine-tuning the performance of the Neural Network.**Test dataset –**This dataset is used to determine the accuracy and margin of error of the Neural Network.

Once the data is segmented into these three parts, Neural Network algorithms are applied to them for training the Neural Network. The procedure used for facilitating the training process in a Neural Network is known as the optimization, and the algorithm used is called the optimizer. There are different types of optimization algorithms, each with their unique characteristics and aspects such as memory requirements, numerical precision, and processing speed.

Before we dive into the discussion of the different **Neural Network algorithms**, let’s understand the learning problem first.

**Also read**: Neural Network Applications in Real World

**What is the Learning Problem?**

We represent the learning problem in terms of the minimization of a loss index (*f*). Here, “*f*” is the function that measures the performance of a Neural Network on a given dataset. Generally, the loss index consists of an error term and a regularization term. While the error term evaluates how a Neural Network fits a dataset, the regularization term helps prevent the overfitting issue by controlling the effective complexity of the Neural Network.

The loss function [*f(w*] depends on the adaptative parameters – weights and biases – of the Neural Network. These parameters can be grouped into a single n-dimensional weight vector (*w*).

Here’s a pictorial representation of the loss function:

According to this diagram, the minimum of the loss function occurs at the point (*w**). At any point, you can calculate the first and second derivatives of the loss function. The first derivatives are grouped in the gradient vector, and its components are depicted as:

Here, *i = 1,…..,n*.

The second derivatives of the loss function are grouped in the **Hessian matrix**, like so:

Here, *i,j = 0,1,…*

Now that we know what the learning problem is, we can discuss the five main

**Neural Network algorithms**.

**1. One-dimensional optimization**

Since the loss function depends on multiple parameters, one-dimensional optimization methods are instrumental in training Neural Network. Training algorithms first compute a training direction (*d*) and then calculate the training rate (*η*) that helps minimize the loss in the training direction [*f(η)*].

In the diagram, the points η1 and η2 define the interval containing the minimum of *f, η**.

Thus, one-dimensional optimization methods aim to find the minimum of a given one-dimensional function. Two of the most commonly used one-dimensional algorithms are the Golden Section Method and Brent’s Method.

**Golden Section Method**

The golden section search algorithm is used to find the minimum or maximum of a single-variable function [*f(x)*]. If we already know that a function has a minimum between two points, then we can perform an iterative search just like we would in the bisection search for the root of an equation *f(x) = 0*. Also, if we can find three points (*x0 < x1 < x2*) corresponding to *f(x0) > f(x1) > f(X2)* in the neighborhood of the minimum, then we can deduce that a minimum exists between *x0* and *x2*. To find out this minimum, we can consider another point *x3* between *x1* and *x2*, which will give us the following outcomes:

- If
*f(x3) = f3a > f(x1),*the minimum is inside the interval*x3 – x0 = a + c*that is related with three new points*x0 < x1 < x3*(here*x2*is replaced by*x3*). - If
*f(x3) = f3b > f(x1*), the minimum is inside the interval*x2 – x1 = b*related with three new points*x1 < x3 < x2*(here*x0*is replaced by*x1*).

**Brent’s Method**

Brent’s method is a root-finding algorithm that combines root bracketing, bisection, secant, and inverse quadratic interpolation. Although this algorithm tries to use the fast-converging secant method or inverse quadratic interpolation whenever possible, it usually reverts to the bisection method. Implemented in the Wolfram Language, Brent’s method is expressed as:

*Method -> Brent in **FindRoot**[eqn, x, x0, x1].*

In Brent’s method, we use a Lagrange interpolating polynomial of degree 2. In 1973, Brent claimed that this method will always converge, provided the values of the function are computable within a specific region, including a root. If there are three points *x1, x2,* and *x3*, Brent’s method fits *x* as a quadratic function of *y*, using the interpolation formula:

The subsequent root estimates are achieved by considering, thereby producing the following equation:

Here, *P = S [ T(R – T) (x3 – x2) – (1 – R) (x2 -x1) ] *and Q = (T – 1) (R – 1) (S – 1) and,

**2. Multidimensional optimization**

By now, we already know that the learning problem for Neural Networks aims to find the parameter vector (*w**) for which the loss function (*f*) takes a minimum value. According to the mandates of the standard condition, if the Neural Network is at a minimum of the loss function, the gradient is the zero vector.

Since the loss function is a non-linear function of the parameters, it is impossible to find the closed training algorithms for the minimum. However, if we consider searching through the parameter space that includes a series of steps, at each step, the loss will reduce by adjusting the parameters of the Neural Network.

In multidimensional optimization, a Neural Network is trained by choosing a random we parameter vector and then generating a sequence of parameters to ensure that the loss function decreases with each iteration of the algorithm. This variation of loss between two subsequent steps is known as “loss decrement.” The process of loss decrement continues until the training algorithm reaches or satisfies the specified condition.

Here are three examples of multidimensional optimization algorithms:

**Gradient descent**

The gradient descent algorithm is probably the simplest of all training algorithms. As it relies on the information provided `from the gradient vector, it is a first-order method. In this method, we’ll take *f[w(i)] = f(i)* and *∇f[w(i)] = g(i)*. The starting point of this training algorithm is w(0) that keeps progressing until the specified criterion is satisfied – it moves from w(i) to w(i+1) in the training direction *d(i) = −g(i)*. Hence, the gradient descent iterates as follows:

*w(i+1) = w(i)−g(i)η(i),*

Here, *i = 0,1,…*

The parameter *η* represents the training rate. You can set a fixed value for *η* or set it to the value found by one-dimensional optimization along the training direction at every step. However, it is preferred to set the optimal value for the training rate achieved by line minimization at each step.

This algorithm has many limitations since it requires numerous iterations for functions that have long and narrow valley structures. While the loss function decreases most rapidly in the direction of the downhill gradient, it does not always ensure the fastest convergence.

**Newton’s method**

This is a second-order algorithm as it leverages the Hessian matrix. Newton’s method aims to find better training directions by making use of the second derivatives of the loss function. Here, we’ll denote *f[w(i)] = f(i), ∇f[w(i)]=g(i)*, and *Hf[w(i)] = H(i)*. Now, we’ll consider the quadratic approximation of *f* at *w(0)* using Taylor’s series expansion, like so:

*f = f(0)+g(0)⋅[w−w(0)] + 0.5⋅[w−w(0)]2⋅H(0)*

Here, *H(0)* is the Hessian matrix of *f* calculated at the point *w(0)*. By considering *g = 0* for the minimum of *f(w)*, we get the following equation:

*g = g(0)+H(0)⋅(w−w(0))=0*

As a result, we can see that starting from the parameter vector w(0), Newton’s method iterates as follows:

*w(i+1) = w(i)−H(i)−1⋅g(i)*

Here, *i = 0,1*,… and the vector *H(i)−1⋅g(i)* is referred to as “Newton’s Step.” You must remember that the parameter change may move towards a maximum instead of going in the direction of a minimum. Usually, this happens if the Hessian matrix is not positive definite, thereby causing the function evaluation to be reduced at each iteration. However, to avoid this issue, we usually modify the method equation as follows:

*w(i+1) = w(i)−(H(i)−1⋅g(i))η*

Here, *i = 0,1*,….

You can either set the training rate η to a fixed value or the value obtained via line minimization. So, the vector *d(i)=H(i)−1⋅g(i)* becomes the training direction for Newton’s method.

The major drawback of Newton’s method is that the exact evaluation of the Hessian and its inverse are pretty expensive computations.

**Conjugate gradient**

The conjugate gradient method falls between the gradient descent and Newton’s method. It is an intermediate algorithm – while it aims to accelerate the slow convergence factor of the gradient descent method, it also eliminates the need for the information requirements concerning the evaluation, storage, and inversion of the Hessian matrix usually required in Newton’s method.

The conjugate gradient training algorithm performs the search in the conjugate directions that delivers faster convergence than gradient descent directions. These training directions are conjugated in accordance to the Hessian matrix. Here, d denotes the training direction vector. If we start with an initial parameter vector [w(0)] and an initial training direction vector *[d(0)=−g(0)]*, the conjugate gradient method generates a sequence of training directions represented as:

*d(i+1) = g(i+1)+d(i)⋅γ(i),*

Here, *i = 0,1*,… and γ is the conjugate parameter. The training direction for all the conjugate gradient algorithms is periodically reset to the negative of the gradient. The parameters are improved, and the training rate (*η*) is achieved via line minimization, according to the expression shown below:

*w(i+1) = w(i)+d(i)⋅η(i)*

Here, *i = 0,1*,…

## Conclusion

Each algorithm comes with unique advantages and drawbacks. These are only a few algorithms used to train Neural Networks, and their functions only demonstrate the tip of the iceberg – as Deep Learning frameworks advances, so will the functionalities of these algorithms.

If you’re interested to learn more about neural network, machine learning & AI, check out IIIT-B & upGrad’s PG Diploma in Machine Learning & AI which is designed for working professionals and offers 450+ hours of rigorous training, 30+ case studies & assignments, IIIT-B Alumni status, 5+ practical hands-on capstone projects & job assistance with top firms.