Enqurious logo
Back to blog
Guides & Tutorials

The Bakery Brain: Simplifying neural networks

The Bakery Brain: Simplifying neural networks blog cover image
Neural Networks
Shuchismita MallickData Scientist


Imagine you're in a bakery, and you're trying to teach a robot how to recognize different types of pastries. Now, this robot has no clue about pastries, but it's eager to learn.


So, you decide to build a mini bakery in the robot's brain using a neural network.


The bakery has little bakers called neurons, and each neuron has a very important job: to decide whether a pastry is a croissant or a donut.


To train the robot, you show it a bunch of pastries. You say, "Hey robot, this flaky one is a croissant, and this circular one is a donut." The robot's neurons start analyzing the pastries.

Now, imagine that each neuron has its baking specialty. Some are experts in analyzing the flakiness of pastries, while others excel in judging their roundness. Each neuron takes its assigned task seriously. But here's the twist: these bakers have a unique way of expressing their opinions. Instead of shouting out their judgments, they raise colorful flags based on the pastry's characteristics. To decide which flag to raise, each baker has an activation function, which determines the output based on the input it receives. 

For example, a neuron that prefers flaky pastries might raise a yellow flag when it detects a high level of flakiness. Another neuron that enjoys circular pastries might raise a blue flag when it sees a perfectly round shape. Now, here's where things get interesting. The strength of the connection between bakers determines how much weight their flags carry in the decision-making process. Stronger connections mean the baker's opinion has more influence. 

To adjust these connections, the bakers gather for a special "weights and biases" ceremony. They discuss and negotiate the importance of their flags, considering factors like their expertise and experience. Some bakers argue passionately for their preferred flag colors, while others compromise to reach a balanced decision.

The input layer of our bakery committee receives the initial data, which in our case is the characteristics of a pastry. Each neuron in the input layer takes a specific characteristic, like flakiness or roundness, and passes it to the hidden layers for further processing.

The hidden layers, represented by groups of bakers with interconnected flags, perform computations on the input data. They analyze the different characteristics, combine the information from multiple neurons, and start making sense of the pastry in question. The bakers in the hidden layers engage in lively discussions. They share their opinions, exchange insights, and collectively refine their understanding of the pastry. It's a dynamic process where the bakers collaborate and learn from each other to form a coherent decision


Finally, after much internal deliberation, the hidden layers arrive at their own collective decision. They pass this decision to the output layer, which consists of a select few seasoned bakers who have mastered the art of making final judgments.

Follow this link for a quick demo

After the weights and biases ceremony, the bakers step back and examine the decisions they made about the pastries. Sometimes, despite their best efforts, they realize that their flags didn't accurately represent the true nature of the pastries. They might have misjudged the flakiness or overlooked certain characteristics.

However, our bakers are not discouraged by their mistakes. Instead, they embrace them as opportunities to learn and improve their judgments. The bakers gather around a table covered in pastries. They study their flags and engage in discussions about what went wrong and how they can adjust their preferences to make better judgments.

During these feedback sessions, the bakers share their experiences and insights. They learn from one another, and collectively, they develop a deeper understanding of the nuances of pastry recognition. It's a collaborative process where the bakers challenge and inspire each other to refine their judgments.

This feedback loop is precisely what backpropagation is all about in the world of neural networks. Just like our bakers, neural networks use backpropagation to learn from their mistakes and improve their predictions. Additionally, to fine-tune the overall decision-making process, each neuron has a personal bias, like a secret ingredient. This bias allows them to shift their preferences (activation functions) and influence their output. It's their way of adding a pinch of individuality to the bakery committee's decision.

So, in our bakery, neurons are like specialized bakers who receive inputs, perform calculations based on their preferences (activation functions), raise flags representing their judgments, and adjust their weights and biases during the weights and biases ceremony.

Follow this link for a quick demo