A Neural Networks Lesson (and Peruvian Sánguches*)
Understanding neural networks through an unlikely teacher: the quest to find Peru's perfect sánguche 🥪
*Sánguches: Peru's mouthwatering take on sandwiches, where traditional ingredients meet culinary creativity.
Let's understand how a neural network works and how we can use it to separate the delicious from the disastrous – all through the lens of Peru's beloved sánguches. 🥪
Neural Networks + Sánguches... WTF?
It might seem like a strange, nonsensical combination – like putting ice cream in a sandwich (which, by the way, some brave chefs have actually tried!). But I promise if you keep reading, everything will click into place. Ready to see how your favorite street food can teach you about artificial intelligence? (if it’s not still your favorite street food, maybe a trip to Peru is a must 😉)
This week I was reading the book "You Look Like a Thing and I Love You" by Janelle Shane, and I found a brilliant example that describes neural networks using sandwiches. But why stick to regular sandwiches when we can explore this with our amazing Peruvian sánguches?
I promise this won't just be a fun journey through Peruvian flavors – by the end of this article, you'll never look at neural networks (or sánguches!) the same way again. You'll understand complex AI concepts through something we all love: the eternal quest for the perfect sandwich.
The Problem
Imagine discovering a mysterious hole in the ground that's like a chaotic sánguche-making machine, spitting out a new creation every few seconds. The catch? It's completely random and a bit chaotic! One moment it might combine chicharrón (our beloved crispy fried pork) with perfectly caramelized onions – yum! But the next creation might be a horrifying mix of lúcuma ice cream (a creamy Peruvian fruit dessert), dirty socks, and rocoto (a fiery hot Peruvian chili pepper) – definitely not something you'd want to serve to hungry customers!
If we wanted to find the truly delicious ones, we'd have to camp out in front of this magical hole all day, tasting and classifying each sánguche. With only one in a thousand being actually delicious, we'd probably end up with a stomach ache before finding a winner. There has to be a better way, right?
Enter our hero: the neural network! But how can a computer possibly understand what makes a sánguche delicious? Let's break this down into a challenge any computer can understand.
First, we'll assume our neural network can identify all the ingredients in each sánguche (no actual tasting required – phew!). Its job is simple: decide whether to save this creation to share with hungry humans or quietly dispose of it. We're essentially teaching a computer to be a sánguche critic!
As we saw in our previous article, neural networks have three key parts:
An input layer (our sánguche ingredients)
An output layer (which tells us if it's delicious or not – we'll call this the "deliciousness factor")
And in between, the hidden layers where the real magic happens
Ready to peek inside these hidden layers and see how our neural network learns to become a sánguche connoisseur?
Building Our Sánguche-Rating Neural Network
Picture this: we're going to build a food critic in the form of a neural network! First, let's connect all our ingredients (the inputs) to what we really care about: the "deliciousness factor" (our output). It's like creating a recipe-rating machine that knows chicharrón with perfectly caramelized onions deserves a chef's kiss 👨🍳, while a sánguche stuffed with lúcuma ice cream and dirty socks deserves... well, the trash bin. ¡Puaj! (That's Peruvian for "Yuck!")
Now you might be wondering, "How does this digital food critic actually judge our sánguches?" Great question! Just like a human food critic develops their taste over time, our neural network needs to learn what makes a sánguche amazing or awful.
Let's start with something simple: each ingredient contributes its own "deliciousness points" to the final score. Think of it as giving each ingredient a rating from 0 to 1, where:
Traditional sánguche ingredients like chicharrón = 1 (¡Riquísimo! / Delicious!)
Questionable additions like dirty socks = 0 (¡Puaj! / Yuck!)
Ready to see how these ingredients work together to create either culinary masterpieces or dining disasters?
Adding Complexity: Teaching Our Network "Good Taste"
Remember our simple rating system? Well, it turns out judging food isn't that simple (any food critic would tell you that!). Let's make our neural network a bit more sophisticated.
First Attempt: The Simple Rating System
We started by giving each ingredient a score:
Chicharrón (crispy pork)? That's a solid 1 point - ¡Riquísimo!
Fresh rocoto (spicy pepper)? Another 1 point - ¡Perfecto!
Dirty socks? Big fat 0 - ¡Puaj!
Lúcuma ice cream? In a sánguche? That's a 0 (save it for dessert!)
At first glance, this seems reasonable:
Chicharrón + rocoto = 2 points (a classic Peruvian combo!)
Dirty socks + lúcuma ice cream = 0 points (disaster avoided!)
But wait... there's a problem. Our simple system would give a chicharrón and lúcuma ice cream sánguche a score of 1 point (1+0=1), suggesting it's "kind of good." Any Peruvian would tell you that's just wrong!
Time for an Upgrade
We need our neural network to understand that some ingredients are like best friends (chicharrón and onions), while others should never, ever meet (chicharrón and ice cream). This is where hidden layers come in - they're like the sophisticated palate of our digital food critic!
Ready to see how we can teach our network about these complex flavor relationships?
Teaching Our Network "The Art of Sánguche Making"
Remember our digital food critic? Time to give it a culinary education! Just like a chef learns that some ingredients create magic together while others spell disaster, our neural network needs to understand these sophisticated relationships.
Introducing: The Food Crime Detective
We'll add a special neuron called the "Bad Sánguche Maker" (think of it as our food crime detective 🕵️♂️). Its job? Catching horrible ingredient combinations before they ruin someone's day!
Here's how our detective works:
It keeps a watchful eye on ALL ingredients
Good ingredients get a low alert score (0)
Suspicious ingredients get a high alert score (10)
When it spots a bad combination, it sends a strong negative signal (-100) to the deliciousness score
Let's see it in action with a real example:
Imagine someone tries to make a sánguche with lúcuma ice cream and dirty socks (¡Qué horror! / How horrible!). Our food detective would:
Spot these suspicious ingredients (10 points each)
Multiply by its negative power (-100)
Send a strong "DON'T MAKE THIS!" signal (-2000 points!)
This way, even if some other part of our network thinks "well, lúcuma is tasty..." our detective makes sure the final verdict is clear: ¡No way!
From Food Critic to Culinary Genius: Our Network's Final Form
Now our neural network isn't just avoiding disasters – it's learning to recognize culinary masterpieces! Here's how it becomes a true sánguche connoisseur:
The Power of Negative Feedback
That massive -2000 score from our food detective? It's like a giant "NOPE!" sign for any weird combinations. But this is just the beginning...
Creating Culinary Excellence
Just like a master chef, our network now has specialized "taste experts":
The "Classic Combo Critic" 👨🍳: Celebrates perfect pairs like chicharrón with crispy onions (¡Uffff! - that's Peruvian for "Amazing!")
The "Harmony Inspector" 🎵: Makes sure ingredients dance well together
The "Balance Master" ⚖️: Checks if flavors complement each other
Beyond Basic Combinations
With enough of these specialized neurons, our network becomes as sophisticated as a Peruvian food critic! Speaking of which... imagine if the legendary Gastón Acurio (think of him as Peru's Gordon Ramsay, but way friendlier) programmed this network. We might discover revolutionary combinations like:
Tacu-tacu (rice and beans patty) topped with
Ají de gallina (creamy chicken chili sauce) and
A surprising touch of pisco sour ice cream
But remember – we're not all culinary geniuses like Gastón! That's why we need our neural network to help us find the perfect balance between tradition and innovation.
From Janelle's Sandwiches to Peruvian Sánguches: A Neural Network Journey
First and foremost, I have to acknowledge Janelle Shane's brilliant sandwich example from "You Look Like a Thing and I Love You." Her creative way of explaining neural networks inspired this entire Peruvian adaptation. Just as she made AI concepts accessible through everyday sandwiches, I wanted to share that same clarity through our beloved sánguches.
Building on her fantastic foundation, we've taken a journey from a magical sánguche-producing hole to understanding the sophisticated decision-making of neural networks. Along the way, we've seen how:
Simple rules (like ingredient ratings) can evolve into complex understanding
Hidden layers work like experienced chefs, recognizing what combinations work
Neural networks, like good cooks, learn from both successes and failures
The beauty of Janelle's original example, which I've flavored with Peruvian ingredients, isn't just in making AI more digestible (pun intended! 😉) – it shows how neural networks can tackle all sorts of real-world challenges. Whether you're classifying sánguches or solving complex business problems, the principles remain the same: break down complex decisions into layers of simpler ones.
Speaking of sánguches... all this AI talk has made me hungry! Time to grab a classic chicharrón sánguche. Sometimes the best solutions are the traditional ones!
¡Hasta pronto! (See you soon!)
Germán
Credit: This article adapts and builds upon an excellent example from "You Look Like a Thing and I Love You: How Artificial Intelligence Works and Why It's Making the World a Weirder Place" by Janelle Shane. Her creative approach to explaining AI concepts through sandwiches made this Peruvian adaptation possible. I highly recommend reading her book and following her fascinating work on AI Weirdness.
Hey! I'm Germán, and I write about AI in both English and Spanish. This article was first published in Spanish in my newsletter AprendiendoIA, and I've adapted it for my English-speaking friends at My AI Journey. My mission is simple: helping you understand and leverage AI, regardless of your technical background or preferred language. See you in the next one!