Alice and the Frog of Destiny (2/3)
A short story about Convolutional Neural Networks
Reading part 1 first is highly recommended :)
Bacchus picked up the three maps of Tomato Island and stacked them on top of each other. He carefully placed one of the kaleidoscopes on top of the stack, so that it was perfectly aligned with the 5 by 5 grid in the top left corner and then pressed a small button on the side of the kaleidoscope.
“0.72451!” squealed the device.
“Very good!” said the wizard, jotting down the number onto another piece of paper. He slid the kaleidoscope one square to the right and pressed its nose again.
“If you say so!” The wizard wrote the number adjacent to the previous one.
“What are you doing?” Alice asked, before the wizard could continue.
“I’m simply asking my friend here what it can see” replied Bacchus. “Each time I press the button, it looks at the values of the 75 squares directly underneath — a 5 by 5 grid from each of the three maps — and passes each value through the corresponding lens.
Alice peered in through the window on the small device and saw 75 lenses also arranged into three 5 by 5 grids.
“Each lens either makes its value larger, smaller or sometimes, if the lens is concave, can even turn it negative. When every value has been transformed through a lens, the device sums them all up and shouts out the answer!”
Alice didn’t look impressed. “So, if you move the kaleidoscope across the maps, you’ll eventually end up with a completely new grid of numbers?”
“That’s right — a 28 by 28 grid to be precise, unless of course, we assume that the pirates don’t like paddling in the 2 metres of sea around each island, so score it zero. Then we can maintain the original 32 by 32 shape of the map — that’s called zero-paddling.”
Alice picked up another one of the kaleidoscopes. “So what do the rest of them do?”
“Well, as with most things, it’s always best to get a few different opinions before making a decision. So, we don’t just ask one kaleidoscope, but twenty!” Bacchus loaded the devices into a large machine. “Each one outputs a very different summary of the maps, even though they’re all given the same input. Watch!”
The wizard pulled a large lever on the floor. The contraption started to whirr and hiss as each kaleidoscope was passed steadily across the stack of maps, lingering on each 5 by 5 set of squares momentarily to shout out a number, which the machine recorded and noted down.
Before long, the machine had finished and 20 sheets of paper lay in the out-tray, each containing a different 28 by 28 map with yet more numbers describing each square.
“How can this have possibly helped?” Alice said, feeling less sure than ever that she would one day find the Frog of Destiny. “There are even more numbers now than on the pirates’ original maps!”
“Relax!” cried the wizard “Or should I say, ReLUx? Perhaps, wait for the ink to dry…”
As Alice was about to protest that this wouldn’t make any difference, she caught sight of some of the numbers disappearing before her very eyes, as the ink evaporated off the page.
“The negatives numbers are disappearing!” she exclaimed.
“Yes — so now you see that things aren’t quite so straightforward…quite non-linear in fact, after the negative numbers have been rectified and replaced with zeros.”
Alice still wasn’t satisfied. “There’s still so much paper — can’t we at least lose a few of these sheets?”
Bacchus thought for a moment. “I’ve got a better idea — put them into this washing machine. We might be able to shrink them.”
This sounded like a bad idea to Alice, but she went along with it anyway, carefully loading the 20 sheets of paper into the drum. It was only then that she noticed that big grinning face on the glass door of the machine.
“Don’t tell me that this can speak too?” she asked, in disbelief.
“No,” replied Bacchus, “Though he does have a name. Alice, meet Maximus Pool.”
“Pleased to meet you Maximus…” Alice said, hesitantly, as she clicked the door shut. The washing machine grinned back, then began to spin, faster and faster as the sheets of paper flashed around inside of the drum.
A few minutes later, the machine stopped and Alice tentatively opened the door. As promised by the wizard, each sheet was now a quarter of the size — a 14 by 14 grid.
“It worked! How did it manage that?”
“Quite simple really. Maximus is quite greedy so just chooses to keep the maximum value in each distinct set of 2 by 2 squares and throw away the rest,” Bacchus explained. “But now, we need more kaleidoscopes — I think we are close to being able to find the Frog of Destiny!”
“More kaleidoscopes?” Alice said, rolling her eyes.
“Yes, but these are slightly different.” Bacchus opened another drawer and took out 50 more silvery objects, that were much longer than the first batch and slightly thinner. He loaded them carefully into the conver-lution layer.
“Ah, I think I know why these are longer!” Alice said. “Before we only had three maps, so we only needed three groups of lenses inside the device, but now we have twenty maps, we’ll need…twenty!”
She peered into one of the new kaleidoscopes and saw twenty layers of lenses arranged into 3 by 3 grids.
“But why are there only 3 by 3 grids of lenses this time instead of 5 by 5?”
“I’ve been experimenting with many different cross-section sizes but found that 3 by 3 seemed to work well for this step — let’s give them a try!
As before, Bacchus stacked the twenty sheets, aimed the machine at the pile of paper and pulled the lever. The machine burst into life, each kaleidoscope squealing numbers as it passed over the sheets. Soon, 50 new sheets of paper lay on the floor in front of them, each containing a 12 by 12 grid of values.
“I think I know what we need to do now!” Alice said, gathering up the sheets. “Maximus Pool — I have another job for you!”
“Wait for the ink to dry first remember!” the wizard called after her, as again the negative numbers gradually evaporated, to be replaced by zeros.
The washing machine happily gobbled up the sheets, span them around at an impossible speed and eventually stopped, the door opening with a click. Much to Alice’s delight, the 50 sheets were now a quarter of the size again — now just tiny squares of paper, each containing a 6 by 6 grid.
“Now what?” Alice asked, unsure if they should go through the conver-lution and Maximus Pooling steps again.
“One final stage!” declared the wizard, opening a door to a dimly lit room filled with a tangle of red and green wires, all of different thicknesses. At the back of the room, there were three glass boxes, each on a pedestal that was connected to many hundreds of the wires. The first contained a single tomato, the second a statue of a frog and the third a pair of sunglasses…
To be continued…. for part 3, click here
Please do leave a ‘clap’ or ‘heart’, if you would like to hear part 3 of the story…
I’m co-founder of Applied Data Science, a London based consultancy that implements end to end data science solutions for businesses. If you’re a business that wants to do more with your data, do get in touch.