<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CoffeeBeans Consulting</title>
    <description>The latest articles on DEV Community by CoffeeBeans Consulting (@coffeebeans).</description>
    <link>https://dev.to/coffeebeans</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F5624%2F792d6229-1ffe-4c7c-b243-e8137c1a022b.png</url>
      <title>DEV Community: CoffeeBeans Consulting</title>
      <link>https://dev.to/coffeebeans</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coffeebeans"/>
    <language>en</language>
    <item>
      <title>Extending Linear Programming to Statistical Learning</title>
      <dc:creator>Pratik Patre</dc:creator>
      <pubDate>Tue, 21 Jun 2022 06:48:13 +0000</pubDate>
      <link>https://dev.to/coffeebeans/extending-linear-programming-to-statistical-learning-24l</link>
      <guid>https://dev.to/coffeebeans/extending-linear-programming-to-statistical-learning-24l</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;What is linear programming?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In simple words, it is a mathematical solution to a complex problem. Believe it or not, we have been using linear programming in everyday life (technically not programming in our minds but the concept). Simple examples would be packing your bag for a trip, managing time in an exam or buying a variety of chocolates within the set budget. It is basically an optimisation problem that we try to solve and by saying that I meant frequentist techniques like Maximum Likelihood (MLE). Mathematically, we usually solve by using some kind of variables and constraints to get the maximum or the minimum of the objective set.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;The process to formulate a Linear Programming problem?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let us look at the steps of defining a Linear Programming problem generically:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;We first decide the unknowns which act as decision variables&lt;/li&gt;
&lt;li&gt;We define the objective function&lt;/li&gt;
&lt;li&gt;Identify the constraints i.e. the system of equalities or inequalities representing the restrictions on the decision variables&lt;/li&gt;
&lt;li&gt;Non-negativity restriction&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;For a problem to be a linear programming problem, the decision variables, objective function and constraints all have to be linear functions. If all the three conditions are satisfied, it is called a Linear Programming Problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Linear Programming in action&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Ordinary Least Squares (OLS) Basics&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Let  us see how linear programming can be clubbed with gradient descent and used in linear regression in machine learning to solve an optimisation problem. Let's start simple, in linear regression we predict a quantitative response y on the basis of a single predictor variable x. It assumes a linear relationship between x and y i.e. &lt;strong&gt;y ~ w0 + w1*X&lt;/strong&gt;. We use the training data to produce model coefficients w0 and w1. We can predict yhat based on X = x i.e. &lt;strong&gt;yhat = w0 + w1*x&lt;/strong&gt;. Using the training data we find a line that most closely represents the data points. There are various ways to measure what it means to closely represent. We may, for instance, minimise the average distance (deviation) of the data points from the line, or minimise the sum of distances, or the sum of squares of distances, or minimise the maximum distance of a datapoint from the line. Here the distance can be either Euclidean distance, or vertical distance, or Manhattan distance (vertical+horizontal), or other.&lt;br&gt;
We choose to minimise the maximum vertical distance of a point from the line. In two dimensional space, a general equation of a line with finite slope has the form &lt;strong&gt;y = w0 + w1*x&lt;/strong&gt; where w0 and w1 are parameters (slope and constant respectively). For a point (p, q), the vertical distance of the point from the line &lt;strong&gt;y = w0 + w1*x&lt;/strong&gt; can be written as &lt;strong&gt;|q − w1*p − w0|&lt;/strong&gt; which is nothing but residual (e1) and if we square it and sum it over n number of points in our data, we get the residual sum of squares i.e. &lt;strong&gt;RSS = e1² + e2² ….en²&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Let's Start with an Example&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Defining decision variable and objective function&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Now consider, we want to predict a house's price with respect to one variable which is the area of the house. So this is our decision variable which we denote as x. Say for a sample point, &lt;strong&gt;g(w) = w0 + w1*x&lt;/strong&gt; is the expected price of a house based on x area of the house. Now, &lt;strong&gt;y = g(w) = w0 + w1*x&lt;/strong&gt; will be marked as an objective function as we have to optimise this line to best fit the data.&lt;/p&gt;

&lt;p&gt;Now I will not go into the proof but if we consider the partial derivative of y with respect to w0 and w1 and represent that in a vector form that's when we get the gradient of y. So, below would be the mathematical expression.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nJctICJl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kkduv5wq7rgob89bw3nj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nJctICJl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kkduv5wq7rgob89bw3nj.png" alt="Image description" width="880" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The cost function is the residual sum of squares and the gradients for the RSS with respect to w0 and w1 will be as shown by &lt;strong&gt;RSS(w0,w1)&lt;/strong&gt; above in vector form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Defining Constraints&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
So now we can define our constraints,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We will have to update the w0 and w1 based on the following equations:&lt;br&gt;
w0 = w0 -Learning rate * partial derivative of RSS function with respect to w0&lt;br&gt;
For simplicity we can write it &lt;strong&gt;w0 = w0 + 2N * B&lt;/strong&gt;…………..(2)&lt;br&gt;
Where B = (sum of errors after prediction over all data points)&lt;/p&gt;

&lt;p&gt;w1 = w1 -Learning rate * partial derivative of RSS function with respect to w1&lt;br&gt;
For simplicity we can write it &lt;strong&gt;w1 = w1 + 2N * C&lt;/strong&gt;..…………(3)&lt;br&gt;
Where C = (sum of (errors*x) after prediction over all data points)&lt;/p&gt;

&lt;p&gt;We repeat the above two steps until convergence, i.e. until &lt;strong&gt;B-C &amp;lt; t&lt;/strong&gt; (tolerance value)&lt;/p&gt;

&lt;p&gt;Now we can rewrite it as &lt;strong&gt;B + (-C) &amp;lt; t&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Squaring on both sides &lt;strong&gt;(B + (-C))² &amp;lt; t²&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Subtracting 2*B*C on both sides &lt;strong&gt;(B + (-C))² -2*B*(-C) &amp;lt; t²- 2*B*(-C)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now a² + b² formula, LHS will turn to be &lt;strong&gt;B² + (-C)²&lt;/strong&gt; i.e. &lt;strong&gt;B² + C² &amp;lt; t² + 2*B*C&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Taking square root on both the sides we get&lt;br&gt;
&lt;strong&gt;Square root(B² + C²) &amp;lt; square root(t² + 2*B*C)&lt;/strong&gt; ………….(1)&lt;/p&gt;

&lt;p&gt;Now technically the convergence is the magnitude of the gradient vector = 0 but in practice we consider the magnitude of the gradient vector &amp;lt; T&lt;br&gt;
Where T is tolerance value&lt;/p&gt;

&lt;p&gt;Now as per the equation (1), the LHS is nothing but the magnitude of the gradient vector and the RHS is the Tolerance value. We can rewrite (1) as follows&lt;br&gt;
&lt;strong&gt;Square root(B² + C²) &amp;lt; T&lt;/strong&gt; ………….(1a)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Defining Non-negativity restriction&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
The non-negativity restriction i.e. the area of the house will be greater than or equal to zero x &amp;gt;= 0.&lt;/p&gt;

&lt;p&gt;So now we have formulated our linear program with the help of gradient descent, let us solve for the optimum line.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Operationalising Linear Programming&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let's consider the following data points&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sHsPyXUG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/av5jegqj6h05t6pnf7wz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sHsPyXUG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/av5jegqj6h05t6pnf7wz.png" alt="Image description" width="395" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We start with assuming intercept = w0 = 0 and slope = w1 = 0 and by setting stepsize or learning rate = 0.025 and tolerance = 0.01&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; We predict and find for yhat based on &lt;strong&gt;yhat = w0 + w1*x&lt;/strong&gt;.&lt;br&gt;
We get the following predictions for the five data points [0,0,0,0,0]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; We find the errors after prediction by yhat - y&lt;br&gt;
We get the following errors [-1,-3,-7,-13,-21]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; We update the intercept by summing the errors and inserting it into equation (2) to get&lt;br&gt;
0 + 2*0.025*sum([-1,-3,-7,-13,-21]) = -2.25&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; We update the slope by summing the multiplication of errors and respective area of house as per equation (3). Thus equation 3 will turn to be:&lt;br&gt;
0 + 2*0.025*sum([0, 1, 2, 3, 4] * [-1, -3, -7, -13, -21]) = -7&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; We calculate the magnitude which is LHS from equation (1a):&lt;br&gt;
sqrt(( -45)² + (-140)²) = 147.05&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; We check equation (1a) to see if it converged. Since 147.05 is greater than 0.01 (the tolerance value set by us), we repeat the steps again but this time with the updated w0 and w1.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since the purpose of this session is to see how linear programming can be used in OLS, we will stop here. But feel free to code this and get the optimum value for w0 and w1.&lt;/p&gt;

</description>
      <category>statistics</category>
      <category>machinelearning</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Activation functions in Neural Networks | Deep Learning</title>
      <dc:creator>lakshaywadhwa7</dc:creator>
      <pubDate>Mon, 20 Jun 2022 07:32:58 +0000</pubDate>
      <link>https://dev.to/coffeebeans/activation-functions-in-neural-networks-deep-learning-58lo</link>
      <guid>https://dev.to/coffeebeans/activation-functions-in-neural-networks-deep-learning-58lo</guid>
      <description>&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  What are activation functions and why we need those?
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Activation functions are functions which are used in the Artifical Neural Networks to capture the complexities inside the data. A neural network without an activation function is just a simple regression model.The activation function does the non-linear transformation to the input making it capable to learn and perform more complex tasks.We introduce non-linearity in each layer through activation functions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--reU35bJ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/epmvkud8jc9mtwv8it4j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--reU35bJ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/epmvkud8jc9mtwv8it4j.png" alt="Image description" width="880" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us assume there are 3 hidden layers, 1 input and 1 output layer.&lt;br&gt;
W1-Weight matrix between Input layer and first hidden layer&lt;br&gt;
W2-Weight matrix between first hidden layer and second hidden layer&lt;br&gt;
W3-Weight matrix between second hidden layer and third hidden layer&lt;br&gt;
W4-Weight matrix between third hidden layer and output layer&lt;br&gt;
Below mentioned equations represents a feedforward neural network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8OBXZBdq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qaqu6qo9sgf8scie5kww.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8OBXZBdq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qaqu6qo9sgf8scie5kww.png" alt="Image description" width="262" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we stack multiple layers, we can see output layer as a function:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xh4lGG3W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dbzne2x5g99x1u8kf1zr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xh4lGG3W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dbzne2x5g99x1u8kf1zr.png" alt="Image description" width="462" height="137"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are Ideal qualities of an activation function:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Non-Linearity:&lt;/strong&gt;&lt;br&gt;
The activation function generally introduce non-linearity in the network to capture the complex relations between input features and output variable/class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Continuously differentiable:&lt;/strong&gt;&lt;br&gt;
The activation function needs to be differentiable since neural networks are generally trained using gradient descent process or to enable gradient based optimzation methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Zero centered:&lt;/strong&gt;&lt;br&gt;
Zero centered activations functions makes sure that mean activation value is around 0. This is important because convergence is usually seen faster on normalized data. I have explained many of the commonly used activation below, some are zero centered some are not. Mostly when we have a activation function which is not zero centered we tend to use normalization layers like batch normalization to mitigate this issue.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Computational expense should be low:&lt;/strong&gt;&lt;br&gt;
Activation functions are used in each layer of the network and is computed a lot of times, hence its computation should be easy and not very computationally expensive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Killing gradients:&lt;/strong&gt;&lt;br&gt;
Activation functions like sigmoid has a saturation problem where the value doesn't change much for large negative and large positive values.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FmaZcTwm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdu9zna889v3iy9682wk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FmaZcTwm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdu9zna889v3iy9682wk.png" alt="Image description" width="623" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The derivative of the sigmoid function gets very small there which in turn prevents the updation of the weights in inital layers during backpropagation and hence the network doesn't learn effectively. This should be avoided to learn patterns in the data and hence the activation function should not ideally suffer from this issue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Most commonly used activation functions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this section we will go over different activation functions.&lt;br&gt;
1.Sigmoid function-&lt;/p&gt;

&lt;p&gt;The sigmoid function is defined as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zSzWCRjI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4rlnpfi4twn5p4g9xy7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zSzWCRjI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4rlnpfi4twn5p4g9xy7.png" alt="Image description" width="491" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Sigmoid function&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O3p-7liZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i217ygyo1m4rz6vul42b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O3p-7liZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i217ygyo1m4rz6vul42b.png" alt="Image description" width="623" height="419"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The sigmoid function is a type of activation function which has a chracteristic "S" shaped curve which has domain of all real numbers and output between 0 and 1. An undesirable property of the sigmoid function is that the activation of the neuron saturates either at 0 or 1 when the input from the neuron is either large positive and large negative. It is also non-zero centered which makes neural network learning difficult. In almost majority of the cases, it is always better to use Tanh activation function instead of sigmoid activation function.&lt;/p&gt;

&lt;p&gt;2.Tanh function-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y92lbinF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osbetfw3s8tdakhrarg3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y92lbinF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osbetfw3s8tdakhrarg3.png" alt="Image description" width="378" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;tanh function&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mXiHkae8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8alqlry59hlt8ftv4jn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mXiHkae8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8alqlry59hlt8ftv4jn.png" alt="Image description" width="880" height="405"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Tanh has just one advantage over sigmoid function that it is zero-centered and it's value is binded between -1 and 1.&lt;/p&gt;

&lt;p&gt;3.RELU(Rectified Linear Unit)-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BZdcjSmB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hqh6t4ab2kq1ldlcbsd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BZdcjSmB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hqh6t4ab2kq1ldlcbsd.png" alt="Image description" width="526" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;relu function&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zsJ2qmO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ll2n45vg732wrtascg1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zsJ2qmO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ll2n45vg732wrtascg1d.png" alt="Image description" width="880" height="457"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;RELU is one of the many non zero-centered activation function and given this disadvantage it is still widely used because of the advantages it has. It is computationally very inexpensive, does not cause saturation and does not cause the vanishing gradient problem. The RELU function doesn't have a higher limit, hence it has a problem of exploding activations and on the other hand for negative values, it has 0 activation and hence it completely ignores the nodes with negative values. Hence it suffers from "dying relu" problem.&lt;br&gt;
Dying ReLU problem: During the backpropagation process, the weights and biases for some neurons are not updated because its nature where activation is zero for negative values. This might create dead neurons which never get activated.&lt;/p&gt;

&lt;p&gt;4.Leaky RELU-&lt;/p&gt;

&lt;p&gt;Leaky RELU is a type of activation function based on RELU function with a small slope for negative values instead of zero.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;leaky relu function&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Vb2THEK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uy4mgkxs3xsjls5zpz4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Vb2THEK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uy4mgkxs3xsjls5zpz4t.png" alt="Image description" width="771" height="559"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MZaFJ3Np--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0yjjwbnlokqsddzk4ye5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MZaFJ3Np--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0yjjwbnlokqsddzk4ye5.png" alt="Image description" width="341" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, alpha is generally set to 0.01. It solves the "dying RELU" problem and also its value is generally small and is not set near to 1 since it will only be a linear function then.&lt;br&gt;
If we use alpha as hyperparameter for each neuron, it becomes a PReLU or parametrized RELU function.&lt;/p&gt;

&lt;p&gt;5.ReLU6-&lt;/p&gt;

&lt;p&gt;This version of ReLU function is basically a ReLU function restricted on the positive side.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--agKsIaRI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7no770zr0c36jsbup69r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--agKsIaRI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7no770zr0c36jsbup69r.png" alt="Image description" width="506" height="80"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;relu6 function&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q3cYIjJ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcedvctvhzgaehlyp4ve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q3cYIjJ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcedvctvhzgaehlyp4ve.png" alt="Image description" width="880" height="656"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This helps in containing the activation function for large input positive values and hence stops the gradient to go to inf value.&lt;/p&gt;

&lt;p&gt;6.Exponential Linear Units (ELUs) Function-&lt;/p&gt;

&lt;p&gt;Exponential Linear Unit is also a version of ReLU that modifies the slope of the negative part of the function.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;exponential linear unit&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ioJ9Wj7n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/th0gvx7082p0d88cry91.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ioJ9Wj7n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/th0gvx7082p0d88cry91.png" alt="Image description" width="625" height="207"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This activation function also avoids dead ReLU problem but it has exploding gradient problem because of no constraint on the activations for large positive values.&lt;/p&gt;

&lt;p&gt;7.Softmax activation function-&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;softmax activation function&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AdCQ28aN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvc60jyh1gsvy6ys7bav.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AdCQ28aN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvc60jyh1gsvy6ys7bav.png" alt="Image description" width="638" height="254"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It often used in the last activation layer of a neural network to normalize the output of a network to a probability value that in turn is mapped to each class which helps us in deciding the probability of output belonging to each class with respect to given inputs.It is popularly used for multi-class classification problems.&lt;br&gt;
I hope you enjoyed reading this. I have tried to cover many of the activation functions which are commonly used in Neural Networks. If any mistake found, please feel free to mention and the blog will be corrected.&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>statistics</category>
      <category>machinelearning</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
