Friday, August 28, 2026
banner
Top Selling Multipurpose WP Theme

Welcome again!

We not too long ago mentioned backpropagation, and I hope you now have an concept of what backpropagation is and the way it truly works.

Let’s proceed the deep studying journey.

Though we apply the backpropagation algorithm to a neural community, we nonetheless have some issues, and vanishing gradients is one in every of them.

Whereas I used to be studying about vanishing gradients, I got here throughout the sigmoid operate.

Everyone knows that it’s utilized in logistic regression, the place we apply the sigmoid operate to a price to acquire an output between 0 and 1.

Now, right here in neural networks, it may be used as an activation operate.

What I learn about sigmoid is the equation we have now and its utilization in logistic regression and neural networks.

I used to be inquisitive about how we get this equation and the story behind it.

On this weblog, let’s have a look at how we get to the sigmoid equation.

By the way in which, if you have not learn Half 3 of the backpropagation collection, you’ll be able to learn it right here.

···

How Do We Truly Use Sigmoid?

We already know the equation of the sigmoid operate.

σ(x)=11+exsigma(x) = frac{1}{1 + e^{-x}}

Earlier than we proceed, let’s have a look at how we use it in logistic regression.

For instance, we wish to predict whether or not a scholar will cross or fail primarily based on the variety of hours they studied.

We’re utilizing the logistic regression mannequin right here.

First, it calculates a rating

For example the rating for a scholar is:

This rating isn’t a likelihood.

It’s simply the linear mixture of parameters.

Now we cross it via the sigmoid operate:

σ(z)=11+ezsigma(z) = frac{1}{1 + e^{-z}}

we get,

σ(2)=11+e20.88sigma(2) = frac{1}{1 + e^{-2}} approx 0.88

The sigmoid operate at all times produces an output between 0 and 1.

Right here the output is roughly 0.88 or 88%.

In logistic regression, this may be interpreted as an 88% likelihood of the coed passing the examination.

We are able to then use a threshold, akin to 0.5, to make the ultimate classification.

Briefly, the stream could be like

RatingSigmoidLikelihoodClasstextual content{Rating} rightarrow textual content{Sigmoid} rightarrow textual content{Likelihood} rightarrow textual content{Class}

That is how we generally use the sigmoid operate in logistic regression.


However What Is This “e”?

Now, let’s as soon as once more have a look at the sigmoid equation.

σ(z)=11+ezsigma(z) = frac{1}{1 + e^{-z}}

The very first thing we discover is the e.

We all know that it’s a mathematical fixed and its worth is

e2.71828e approx 2.71828

However what precisely is ‘e’?

Why is that this quantity current within the sigmoid equation?

Let’s take a step again and perceive the place this quantity comes from.

One factor is that right here we’re not attempting to find ‘e’, however the purpose is to grasp the importance of ‘e’ and see the place it naturally seems.

Now let’s go to the financial institution and see what we are able to observe.


Let’s Begin with a Easy Financial institution Instance

Think about we deposited Rs.100 right into a checking account.

For example the financial institution is giving us a 100% annual rate of interest.

If the financial institution provides all the yr’s curiosity on the finish of the yr, we earn Rs.100 in curiosity.

So after one yr, we have now

100+100=200100 + 100 = 200

We are able to additionally write it as

100(1+1)=200100(1 + 1) = 200

Rs.100 grew to become Rs.200 after one yr.

However now let’s change one factor.

What if the financial institution does not wait till the top of the yr so as to add the curiosity?

What if it provides the curiosity twice a yr?

The annual rate of interest continues to be 100%.

However now the yr is split into two durations.

So for every six-month interval we get half of the annual rate of interest:

12=0.5=50%frac{1}{2} = 0.5 = 50%

Throughout the first six months, we get

100(1+12)=150100left(1 + frac{1}{2}proper) = 150

After six months, we have now Rs.150.

Throughout the subsequent six months, the curiosity is calculated on this new quantity

150(1+12)=225150left(1 + frac{1}{2}proper) = 225

Then we have now

100(1+12)2=225100left(1 + frac{1}{2}proper)^2 = 225

Why did we get Rs.225 as an alternative of Rs.200?

As a result of the curiosity earned through the first six months additionally earned curiosity through the second six months.

In easy phrases we are able to say

‘curiosity earns curiosity’

That is the fundamental concept behind compound curiosity.

What Occurs When We Compound Extra Regularly?

Now let’s make the compounding extra frequent.

If we compound 4 occasions a yr:

100(1+14)4244.14100left(1 + frac{1}{4}proper)^4 approx 244.14

If we compound 12 occasions a yr:

100(1+112)12261.30100left(1 + frac{1}{12}proper)^{12} approx 261.30

If we compound daily:

100(1+1365)365271.46100left(1 + frac{1}{365}proper)^{365} approx 271.46

Observe the sample.

As we enhance the variety of compounding durations, the ultimate quantity retains growing.

The reason being that progress is being utilized repeatedly to an quantity that has already elevated.

The place Does e Come From?

The Rs.100 isn’t the essential half right here.

Let’s take away it and have a look at the expansion issue:

(1+1n)nleft(1 + frac{1}{n}proper)^n

Right here, ‘n’ represents the variety of occasions we compound through the yr.

For instance:

(1+11)1=2left(1 + frac{1}{1}proper)^1 = 2
(1+12)2=2.25left(1 + frac{1}{2}proper)^2 = 2.25
(1+14)42.4414left(1 + frac{1}{4}proper)^4 approx 2.4414
(1+112)122.613left(1 + frac{1}{12}proper)^{12} approx 2.613
(1+1365)3652.7146left(1 + frac{1}{365}proper)^{365} approx 2.7146

As we make the compounding an increasing number of frequent, the worth will get nearer and nearer to

2.718282.71828ldots

This quantity known as ‘e’

e2.71828e approx 2.71828

Mathematically, we are able to categorical this concept utilizing a restrict

e=limn(1+1n)ne = lim_{n rightarrow infty} left(1 + frac{1}{n}proper)^n

The notation could look complicated, however the concept is easy.

Right here, we’re asking:

“What worth does this expression strategy as ‘n’ turns into bigger and bigger?”

As ‘n’ will increase:

(1+1n)nleft(1 + frac{1}{n}proper)^n

will get nearer and nearer to:

2.718282.71828ldots

That limiting worth is ‘e’.


So, What Does the Financial institution Must Do with Sigmoid?

However why are we speaking about this and what does this checking account need to do with sigmoid.

This instance is not to clarify compound curiosity, however it offers us an instinct for the place ‘e’ naturally seems.

The essential concept right here is repeated progress.

When progress is repeatedly utilized to an quantity that has already grown, we get a compounding course of.

And when that course of occurs time and again extra regularly, the quantity ‘e’ naturally seems.

So as an alternative of merely memorizing that

e2.71828e approx 2.71828

we now have some instinct behind it.


The Particular Property of e

From the financial institution instance, we noticed that ‘e’ naturally seems once we have a look at repeated progress and steady compounding.

However ‘e’ is greater than only a quantity that seems in compound curiosity.

It has a really particular property once we have a look at it via calculus.

Let’s contemplate the exponential operate

If we differentiate this operate, we get

dydx=exfrac{dy}{dx}=e^x

This method we already know.

However what does the by-product inform us?

We already know that it tells us the fee of change of a operate.

For instance, if we have now

its by-product is

dydx=2xfrac{dy}{dx}=2x

Which means that the speed at which x2 modifications is dependent upon the worth of x.

At x=1:

dydx=2(1)=2frac{dy}{dx}=2(1)=2

At x=3:

dydx=2(3)=6frac{dy}{dx}=2(3)=6

So, for x2, the operate and its fee of change are totally different.

Now let us take a look at ex.

For

we have now

dydx=exfrac{dy}{dx}=e^x

Which means that the speed of change of ex is the same as its present worth.

Let’s take a look at some values.

When x=0

and

dydx=1frac{dy}{dx}=1

When x=1

e12.718e^1approx2.718

and

dydx2.718frac{dy}{dx}approx2.718

When x=2

e27.389e^2approx7.389

and

dydx7.389frac{dy}{dx}approx7.389

So, right here we are able to say that

Charge of change = Present worth

This is likely one of the most essential properties of the exponential operate with base e.


Why Is the Spinoff of ex Equal to ex?

We now have an concept of an essential property of ‘e’ in calculus.

ddxex=exfrac{d}{dx}e^x=e^x

We simply mentioned what it’s however let’s have a look at why does this occur?

In the event you already know why

ddxex=exfrac{d}{dx}e^x=e^x

then use this part for fast revision as we join it again to the sigmoid operate.

Beginning with a Normal Exponential

First let’s contemplate a basic exponential operate.

Right here, z is the bottom and x is the exponent.

2x,3x,5x,10x2^x,qquad 3^x,qquad 5^x,qquad 10^x

are all examples of this manner.

Now let’s have a look at what occurs once we differentiate zx

Now we have,

dydx=limh0zx+hzxhfrac{dy}{dx} = lim_{hto0} frac{z^{x+h}-z^x}{h}

Utilizing the exponent rule we get

zx+h=zxzhz^{x+h}=z^xz^h

Due to this fact

dydx=limh0zxzhzxhfrac{dy}{dx} = lim_{hto0} frac{z^xz^h-z^x}{h}

Now discover that zx seems in each phrases within the numerator.

We are able to issue it out

dydx=limh0zxzh1hfrac{dy}{dx} = lim_{hto0} z^xfrac{z^h-1}{h}

Right here zx doesn’t rely upon h, so we are able to take it outdoors the restrict

dydx=zxlimh0zh1hfrac{dy}{dx} = z^x lim_{hto0} frac{z^h-1}{h}

And that is the place issues get attention-grabbing.

Our result’s

dydx=zxlimh0zh1hfrac{dy}{dx} = z^x lim_{hto0} frac{z^h-1}{h}

Have a look at the 2 elements individually.

The primary half is

That’s our unique exponential operate.

The second half is

limh0zh1hlim_{hto0} frac{z^h-1}{h}

We are able to see that there isn’t a ‘x’ on this expression.

It is dependent upon the bottom ‘z’, however not on ‘x’.

This implies, for any worth of ‘z’, this whole restrict is only a fixed.

Let’s name this fixed ‘C’.

C=limh0zh1hC= lim_{hto0} frac{z^h-1}{h}

Due to this fact we are able to write it as,

ddxzx=Czxfrac{d}{dx}z^x=Cz^x

This tells us one thing essential.

Once we differentiate an exponential operate, we get the unique exponential operate, multiplied by a continuing.

In different manner,

Spinoff of zx=fixed×zxtextual content{Spinoff of }z^x = textual content{fixed}occasions z^x

The Fixed Is determined by the Base

Now let’s take an instance of exponential operate:

From our end result, we have now

ddx3x=C3xfrac{d}{dx}3^x=C3^x

For z=3, the fixed is

C=limh03h1hC= lim_{hto0} frac{3^h-1}{h}

Now we have to discover the worth of this restrict.

Let’s perceive this in intuitive manner.

For the bottom 3, the worth of the fixed is roughly

C1.0986Capprox1.0986

Due to this fact,

ddx3x1.0986(3x)frac{d}{dx}3^x approx 1.0986(3^x)

Let’s examine what this tells us by utilizing at totally different ‘x’ values.

When

we have now

the speed of change right here is roughly

1.0986(1)=1.09861.0986(1)=1.0986

When

we get

The speed of change is

1.0986(3)3.29581.0986(3)approx3.2958

And when

we have now

The speed of change is roughly

1.0986(9)9.88741.0986(9)approx9.8874

We are able to see that the by-product isn’t precisely equal to 3x.

As a substitute, we bought

ddx3x1.0986(3x)frac{d}{dx}3^x approx 1.0986(3^x)

The operate and its fee of change have the identical exponential form, however the fee of change is scaled by a continuing.


Discovering the Particular Base

Now, we all know that

ddxzx=Czxfrac{d}{dx}z^x=Cz^x

The worth of ‘C’ trusted the bottom.

For 3x,

C1.0986Capprox1.0986

Okay however what if we may discover a base for which C is strictly 1?

Do we have now any quantity?

If sure, then we get

Our by-product would turn into

ddxzx=zxfrac{d}{dx}z^x=z^x

In different phrases, we are able to say that the operate could be precisely equal to its personal by-product.

So, now we’re on the lookout for a base z that satisfies

limh0zh1h=1lim_{hto0} frac{z^h-1}{h}=1

There may be one explicit constructive quantity that satisfies this situation and also you all know what’s that quantity is.

We name this quantity

and its numerical worth is

e2.71828eapprox2.71828

For this explicit base, the fixed turns into

Due to this fact,

ddxex=1exfrac{d}{dx}e^x = 1cdot e^x

which provides us

ddxex=exfrac{d}{dx}e^x=e^x

···

So What Did We Truly Uncover?

We began with a basic exponential operate

Utilizing the definition of a by-product, we discovered

ddxzx=zxlimh0zh1hfrac{d}{dx}z^x = z^x lim_{hto0} frac{z^h-1}{h}

We then noticed that the restrict is solely a continuing that is dependent upon the bottom.

Then we have now written it as

ddxzx=Czxfrac{d}{dx}z^x=Cz^x

Then we requested:

Is there a base for which C=1?

The reply is sure.

That particular base is e.

Due to this fact,

ddxex=exfrac{d}{dx}e^x=e^x

Now we have now an concept of how we bought the by-product.


Within the earlier financial institution instance, ‘e’ appeared via repeated progress and steady compounding.

Now, via calculus, we have now seen one other particular property of the identical quantity

ddxex=exfrac{d}{dx}e^x=e^x

In easy phrases, we are able to say that ex grows at a fee equal to its present worth.


Now, Let’s Return to Sigmoid

Let’s as soon as once more have a look at the sigmoid equation.

σ(x)=11+exsigma(x)=frac{1}{1+e^{-x}}

Now we have now some concept of what ‘e’ truly is.

Now we give attention to the entire equation.

The query right here is why does the sigmoid operate is on this explicit kind?

To know this we must always return to logistic regression.

We began with a uncooked rating

‘z’ could be any actual quantity.

However for classification, we needed to interpret the mannequin’s output as a likelihood.

A likelihood should lie between 0 and 1

0<p<1

So we wish to remodel any worth of ‘z’ into a price between 0 and 1.

In different phrases, we would like one thing that may obtain

z(,)zin(-infty,infty)

and produce:

p(0,1)pin(0,1)

Constructing a Operate That Outputs Between 0 and 1

Now, the duty is to assemble such transformation.

However how can we do this?

Let’s begin with a quite simple remark.

Suppose we have now a quantity better than 1.

For instance

If we take its reciprocal, we get

15=0.2frac{1}{5}=0.2

which is between 0 and 1.

The identical concept works for any numbers better than 1

12=0.5frac{1}{2}=0.5
110=0.1frac{1}{10}=0.1
1100=0.01frac{1}{100}=0.01

Right here we are able to discover that

If

then

0<1A<10 < frac{1}{A} < 1

This provides us a easy concept.

If we are able to have a amount that’s at all times better than 1, then taking its reciprocal will routinely give us a price between 0 and 1.

And that’s precisely the vary we would like for a likelihood.

Nevertheless, there may be yet another factor we want.

We don’t wish to use a set quantity akin to 5 within the denominator.

as a result of that at all times give us the identical output.

Our output ought to change when the enter ‘x’ modifications.

For instance, we would like a constructive enter to supply a bigger likelihood, whereas a destructive enter ought to produce a smaller likelihood.

So, we want a amount that modifications with x.

Now e Enters the Image

You’re proper. It is time for ‘e’ to enter.

That is the place the exponential operate we simply discovered about turns into helpful.

Exponential capabilities are at all times constructive, which implies

for each actual worth of x.

For instance:

e20.1353e^{-2}approx0.1353
e27.389e^2approx7.389

Whether or not the x is destructive, zero, or constructive, ex by no means turns into destructive or zero.

However the sigmoid equation comprises e-x.

Until right here we solely mentioned about ex.

So let’s first see what a destructive exponent means.

We already know what a constructive exponent means.

For instance:

e2=e×ee^2=etimes e

and:

e3=e×e×ee^3=etimes etimes e

A destructive exponent represents the reciprocal of the corresponding constructive exponent.

For instance:

e1=1ee^{-1}=frac{1}{e}

Equally

e2=1e2e^{-2}=frac{1}{e^2}

and

e3=1e3e^{-3}=frac{1}{e^3}

On the whole, we are able to write as

ex=1exe^{-x}=frac{1}{e^x}

So, e-x isn’t a very totally different operate.

It’s merely the reciprocal of ex.

Now we are able to use what we already learn about ex.

Since:

its reciprocal can also be constructive

1ex>0frac{1}{e^x}>0

and since

ex=1exe^{-x}=frac{1}{e^x}

we get

for each actual worth of x.

That is essential as a result of it offers us precisely the sort of amount we want.

If e-x is at all times constructive, then including 1 offers us a amount that’s at all times better than 1

1+ex>11+e^{-x}>1

And now we are able to use our reciprocal concept.

If a quantity is larger than 1, its reciprocal lies between 0 and 1

0<11+ex<10<frac{1}{1+e^{-x}}<1

Now we have now a operate whose output is at all times between 0 and 1.

The expression we simply bought is

11+exfrac{1}{1+e^{-x}}

and that is precisely the sigmoid operate we began with

σ(x)=11+exsigma(x)=frac{1}{1+e^{-x}}

So as an alternative of wanting on the sigmoid equation as a method, now we are able to perceive the instinct behind its construction.

We needed the output to lie between 0 and 1.

We noticed that the reciprocal of a quantity better than 1 lies between 0 and 1.

As e-x is at all times constructive, we used it to assemble a amount better than 1

1+ex>11+e^{-x}>1

Taking its reciprocal gave us

σ(x)=11+exsigma(x)=frac{1}{1+e^{-x}}

This gave us the vary we needed.

However does this equation truly behave the way in which we anticipated it to do?

Right here, our purpose is to grasp the instinct behind the construction of the sigmoid operate.

There are different capabilities that may map values to the vary 0 to 1, and why logistic regression makes use of sigmoid is expounded to odds and log-odds, a subject which we’ll discover in future blogs.


Does the Sigmoid Behave the Approach We Anticipated?

Let’s take a look at on few values.

First, let’s contemplate

Substituting into the sigmoid operate:

σ(0)=11+e0sigma(0)=frac{1}{1+e^{-0}}

as

we get

σ(0)=11+1=0.5sigma(0)=frac{1}{1+1}=0.5

When the enter is 0, the sigmoid offers us precisely 0.5.

Now let’s take a constructive quantity

then

σ(2)=11+e2sigma(2)=frac{1}{1+e^{-2}}

We already seen

e20.1353e^{-2}approx0.1353

which provides

σ(2)=11+0.1353=11.13530.881sigma(2) = frac{1}{1+0.1353} = frac{1}{1.1353} approx 0.881

The sigmoid transformed the enter 2 into roughly 0.881 or 88.1%.

Now let’s have a look at what occurs when the enter is a destructive quantity.

Think about

Then

σ(2)=11+e(2)sigma(-2) = frac{1}{1+e^{-(-2)}}
σ(2)=11+e2sigma(-2) = frac{1}{1+e^2}

We all know

e27.389e^2approx7.389

Lastly we get

σ(2)=11+7.389=18.3890.119start{aligned} sigma(-2) &=frac{1}{1+7.389} &=frac{1}{8.389} &approx0.119 finish{aligned}

So the sigmoid transformed the enter -2 into roughly 0.119 or 11.9%.

Now we are able to see how the sigmoid behaves.

For a destructive enter:

x=2σ(x)0.119x=-2 quadlongrightarrowquad sigma(x)approx0.119

For zero:

x=0σ(x)=0.5x=0 quadlongrightarrowquad sigma(x)=0.5

For a constructive enter:

x=2σ(x)0.881x=2 quadlongrightarrowquad sigma(x)approx0.881

In order x will increase, the sigmoid output strikes from values near 0, passes via 0.5 and strikes towards 1.

Within the excessive instances:

xσ(x)0xrightarrow-infty quadLongrightarrowquad sigma(x)rightarrow0

and

x+σ(x)1xrightarrow+infty quadLongrightarrowquad sigma(x)rightarrow1

That is precisely the habits we needed from a operate that transforms any actual quantity into one thing between 0 and 1.

Picture by Creator

Now we have now an concept of how we bought the equation of the sigmoid operate.

In the event you keep in mind, in my latest blogs, once we mentioned backpropagation and neural networks on the whole, we talked about activation capabilities and why they’re essential.

We used the ReLU activation operate to grasp these ideas.

Now, we are able to additionally use sigmoid as an activation operate.

But when we use sigmoid as an activation operate, there may be yet another factor we have to know.

Throughout the backward cross, we already know that the community calculates gradients utilizing derivatives.

So, if sigmoid is a part of the community, we have to differentiate it as effectively.

Now let’s focus solely on deriving the by-product of the sigmoid operate step-by-step.

σ(x)=11+exsigma(x)=frac{1}{1+e^{-x}}

As a substitute of carrying the exponential time period all through calculations, we are able to merely use the sigmoid output itself.

That is the by-product we use at any time when sigmoid seems within the gradient calculations of a neural community.

···

Abstract

Within the upcoming blogs, we’re going to talk about subjects like vanishing gradients and exploding gradients.

As we discover these subjects, we’ll come throughout the sigmoid operate, and we may also want its by-product.

If we derive the sigmoid operate and its by-product in these blogs, the dialogue may turn into lengthy, and we could lose give attention to the precise idea that we try to grasp.

It will even be higher to have an concept of the place the sigmoid operate and its by-product come from earlier than utilizing them in additional ideas.

We first began with the financial institution instance to see how e seems. We then discovered about its essential property in calculus and, utilizing these concepts, progressively constructed the sigmoid equation.

We noticed how this equation is utilized in logistic regression and neural networks, and we additionally derived its by-product.

Now, once we transfer on to the upcoming subjects, we have already got this basis which shall be helpful for us.


I hope you discovered this weblog useful in understanding an idea that we regularly use.

When you have any questions or recommendations for enchancment, be at liberty to share them within the feedback on LinkedIn.

And if you have not learn my newest weblog collection on backpropagation but, you’ll be able to learn it right here.

Generally, shifting ahead means going again and understanding the fundamentals.

Thanks for studying!

···

banner
Top Selling Multipurpose WP Theme

Converter

Top Selling Multipurpose WP Theme

Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

banner
Top Selling Multipurpose WP Theme

Leave a Comment

banner
Top Selling Multipurpose WP Theme

Latest

Best selling

22000,00 $
16000,00 $
6500,00 $
5999,00 $

Top rated

6500,00 $
22000,00 $
900000,00 $

Products

Knowledge Unleashed
Knowledge Unleashed

Welcome to Ivugangingo!

At Ivugangingo, we're passionate about delivering insightful content that empowers and informs our readers across a spectrum of crucial topics. Whether you're delving into the world of insurance, navigating the complexities of cryptocurrency, or seeking wellness tips in health and fitness, we've got you covered.