Deep Learning Fundamentals - Classic Edition

A newer version of this course is available! Check here for details!

Bias in an Artificial Neural Network explained | How bias impacts training

video

expand_more chevron_left

text

expand_more chevron_left

Bias in an Artificial Neural Network

Hey, what's going on everyone? In this episode, we're going to talk about bias.

Don't worry, we're not changing focus to discuss bias from a social or political standpoint. We'll save that for another series. Instead, we'll be specifically discussing the bias present within artificial neural networks.

Without further ado, let's get to it.

Background

When reading up on artificial neural networks, you may have come across the term bias. It's sometimes just referred to as bias. Other times you may see it referenced as bias nodes, bias neurons, or bias units within a neural network.

We're going to break this bias down and see what it's all about.

We'll first start out by discussing the most obvious question of, well, what is bias in an artificial neural network?

We'll then see, within a network, how bias is implemented.

Then, to hit the point home, we'll explore a simple example to illustrate the impact that bias has when introduced to a neural network.

Understanding Bias Inside Neural Networks

Let's get started by working to understand what exactly bias is inside neural networks.

What is Bias?

So, what is bias in an artificial neural network?

Well, first, when we talk about bias, we're talking about it on a per-neuron basis. We can think of each neuron as having its own bias term, and so the entire network will be made up of multiple biases.

Now, the values assigned to these biases are learnable, just like the weights. Just how stochastic gradient descent learns and updates the weights via backpropagation during training, SGD is also learning and updating the biases as well.

Now, conceptually, we can think of the bias at each neuron as having a role similar to that of a threshold. This is because the bias value is what's going to determine whether or not the activation output from a neuron is going to be propagated forward through the network.

In other words, the bias is determining whether or not, or by how much, a neuron will fire. It's letting us know when a neuron is meaningfully activated. As we'll see in a few moments, the addition of these biases ends up increasing the flexibility of a model to fit the given data.

Where Bias Fits In

Alright, so we have an idea of what bias is now, but where exactly does it fit into the scheme of things? As we've discussed in past episodes, we know how each neuron receives a weighted sum of input from the previous layer, and then that weighted sum gets passed to an activation function.

Well, the bias for a neuron is going to fit right in here within this process. What we do is, rather than pass the weighted sum directly to the activation function, we instead pass the weighted sum plus the bias term to the activation function.

Ok, well, what good is that?

Let's look at a simple example that illustrates the role of this bias term in action.

Example that Shows Bias in Action

Suppose we have a neural network that has an input layer with just two nodes. Suppose the first node has a value of \(1\), and the second node has a value of \(2\).

Now we're going to focus our attention on a single neuron within the first hidden layer that directly follows the input layer.

The activation function we will use for this first hidden layer is relu, and we're going to assign some randomly generated weights to our connections.

Now, let's see what the output of this node would be without introducing any bias.

The weighted sum that this node receives is given by

\[ \left(1\times -0.55\right) + \left(2\times 0.10\right) = -0.35 \text{.} \]

We pass this result to relu. We know that the value of relu at any given input will be the maximum of either zero or the input itself, and in our case, we have

\[ \DeclareMathOperator{\relu}{relu} \relu \left(-0.35\right) = 0 \text{.} \]

With an activation output of zero, the neuron is considered to not be activated, or not firing. In fact, with relu, any neuron with a weighted sum of input is less than or equal to zero will not be firing, and so no information from these non-activated neurons will be passed forward through to the rest of the network.

Essentially, zero is the threshold here for the weighted sum in determining whether a neuron is firing or not.

Well, what if we want to shift our threshold? What if instead of zero, we determined that a neuron should fire if its input is greater than or equal to \(-1\)?

This is where bias comes into play.

Remember, we earlier said that the bias gets added to the weighted sum before being passed to the activation function. The value we assign to our bias is the opposite of this so called threshold value.

Continuing with our example, we want the threshold to move from \(0\) to \(-1\), right? The bias will then be the opposite of \(-1\), which is just \(1\).

The weighted sum of \(-0.35\) plus our bias of \(1\) equals \(0.65\).

\[ \left(1\times -0.55\right) + \left(2\times 0.10 \right) + 1 = -0.35 + 1 = 0.65 \text{.} \]

Passing this value to relu, we can see that

\[ \DeclareMathOperator{\relu}{relu} \relu \left(0.65\right) = 0.65 \text{.} \]

The neuron is now considered to be firing.

The model now has a bit of increased flexibility in fitting the data since it now has a broader range in what values it considers as being activated or not.

We could also do the same process in the opposite direction to narrow what output values from neurons that we consider as being activated. For example, if we determined that a neuron should be considered activated when its output is greater than or equal to five, then our bias would be minus five.

Conclusion

Now, we explicitly choose and set our bias in our example. In practice, this isn't the case. Just as we don't explicitly choose and control the weights in a network, we don't explicitly choose and control the biases either.

Remember, the biases are learnable parameters within the network, just like weights. After the biases are initialized, with random numbers, or zeros, or really any other value, they will be updated during training, allowing our model to learn when to activate and when not to activate each neuron.

quiz

expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Quiz Results

resources

expand_more chevron_left
When reading up on artificial neural networks, you may have come across the term “bias.” It's sometimes just referred to as bias. Other times you may see it referenced as bias nodes, bias neurons, or bias units within a neural network. We're going to break this bias down and see what it's all about. We'll first start out by discussing the most obvious question of, well, what is bias in an artificial neural network? We'll then see, within a network, how bias is implemented. Then, to hit the point home, we'll explore a simple example to illustrate the impact that bias has when introduced to a neural network. Checkout posts for this video: https://www.patreon.com/posts/18290447 https://www.instagram.com/p/BhxuRXhlGpS/?taken-by=deeplizard https://twitter.com/deeplizard/status/987163658391293952 https://steemit.com/deep-learning/@deeplizard/bias-in-an-artificial-neural-network-explained-or-how-bias-impacts-training 🕒🦎 VIDEO SECTIONS 🦎🕒 00:00 Welcome to DEEPLIZARD - Go to deeplizard.com for learning resources 00:30 Help deeplizard add video timestamps - See example in the description 06:42 Collective Intelligence and the DEEPLIZARD HIVEMIND 💥🦎 DEEPLIZARD COMMUNITY RESOURCES 🦎💥 👋 Hey, we're Chris and Mandy, the creators of deeplizard! 👀 CHECK OUT OUR VLOG: 🔗 https://youtube.com/deeplizardvlog 💪 CHECK OUT OUR FITNESS CHANNEL: 🔗 https://www.youtube.com/channel/UCdCxHNCexDrAx78VfAuyKiA 🧠 Use code DEEPLIZARD at checkout to receive 15% off your first Neurohacker order: 🔗 https://neurohacker.com/shop?rfsn=6488344.d171c6 ❤️🦎 Special thanks to the following polymaths of the deeplizard hivemind: Mano Prime 👀 Follow deeplizard: Our vlog: https://youtube.com/deeplizardvlog Fitness: https://www.youtube.com/channel/UCdCxHNCexDrAx78VfAuyKiA Facebook: https://facebook.com/deeplizard Instagram: https://instagram.com/deeplizard Twitter: https://twitter.com/deeplizard Patreon: https://patreon.com/deeplizard YouTube: https://youtube.com/deeplizard 🎓 Deep Learning with deeplizard: AI Art for Beginners - https://deeplizard.com/course/sdcpailzrd Deep Learning Dictionary - https://deeplizard.com/course/ddcpailzrd Deep Learning Fundamentals - https://deeplizard.com/course/dlcpailzrd Learn TensorFlow - https://deeplizard.com/course/tfcpailzrd Learn PyTorch - https://deeplizard.com/course/ptcpailzrd Natural Language Processing - https://deeplizard.com/course/txtcpailzrd Reinforcement Learning - https://deeplizard.com/course/rlcpailzrd Generative Adversarial Networks - https://deeplizard.com/course/gacpailzrd Stable Diffusion Masterclass - https://deeplizard.com/course/dicpailzrd 🎓 Other Courses: DL Fundamentals Classic - https://deeplizard.com/learn/video/gZmobeGL0Yg Deep Learning Deployment - https://deeplizard.com/learn/video/SI1hVGvbbZ4 Data Science - https://deeplizard.com/learn/video/d11chG7Z-xk Trading - https://deeplizard.com/learn/video/ZpfCK_uHL9Y 🛒 Check out products deeplizard recommends on Amazon: 🔗 https://amazon.com/shop/deeplizard 📕 Get a FREE 30-day Audible trial and 2 FREE audio books using deeplizard's link: 🔗 https://amzn.to/2yoqWRn 🎵 deeplizard uses music by Kevin MacLeod 🔗 https://youtube.com/channel/UCSZXFhRIx6b0dFX3xS8L1yQ ❤️ Please use the knowledge gained from deeplizard content for good, not evil.

updates

expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Update history for this page

Did you know you that deeplizard content is regularly updated and maintained?

  • Updated
  • Maintained

Spot something that needs to be updated? Don't hesitate to let us know. We'll fix it!


All relevant updates for the content on this page are listed below.