Better Programming

Advice for programmers.

Follow publication

Coffee is a Neural Network

Another perspective on coffee

Robert McKeon Aloe
Better Programming
Published in
3 min readMar 28, 2023
Photo by Ben Kolde on Unsplash

My professional career has been a mashup of data science, computer vision, and machine learning. When I started to apply these skills to coffee, I found a multi-variable process that was challenging and interesting. As I looked deeper, I found similarities between the entire process of coffee to a neural network.

This is another way to look at the process from bean to cup, and because of my perspective, I see things differently. I thought it might be interesting to share that.

Defining Terms

Here are some terms used in typical neural networks. Back when I started, a neural network only had one or two layers. By 2014, Convolutional Neural Networks (CNNs) were born, and they paved the way to seemingly miraculous algorithm performance.

chart with two columns (name and description. Seven rows. sample/sampling, random sample of available data. conv, compute convolution of a kernel across the image. pooling, downsized with a filter, typically averaging. RELU, clipped the data range. Flatten, covert 2d to 1d. Softmax, cross-entropy loss

The Process of Coffee

I sketched out a rough outline of what coffee looks like as a neural network, assuming that the final experience is espresso (since that’s the only way I brew coffee). So some variables change slightly when looking at pour-over or drip coffee.

chart with two rows (coffee and layer) and 15 columns. species, sample. trees, sampling + conv. harvest, pooling. processing, conv + RELU. roasting, Conv + Pooling. blending, pooling. dose, sampling. grinding, flatten. puck prep, conv. tamping, RELU. extraction, conv. ratio, RELU. cup, pooling. taste, softmax.
All remaining images by author

Coffee starts as a variety of plant species, and a farm chooses a sample. Inside that sample are a variety of trees. When we talk about single-origin coffee, we are talking about single-farm origin. A farm will have multiple trees and varieties, and these trees cross bred every year. So the trees themselves are convoluted with each other and sampled each year.

Harvest is pooling together multiple samples. Then the processing again homogenizes the coffee, and there is a RELU process. A RELU is zero-ing out certain signals, and in the case of coffee, that’s done by sorting beans, removing over/under ripe beans, and sorting by density.

Roasting is a similar process of convolution and pooling because each bean has a different roast profile, so any given roast profile is an average of the total. Blending is pooling flavors from different beans.

chart with two rows (coffee and layer) and 15 columns. species, sample. trees, sampling + conv. harvest, pooling. processing, conv + RELU. roasting, Conv + Pooling. blending, pooling. dose, sampling. grinding, flatten. puck prep, conv. tamping, RELU. extraction, conv. ratio, RELU. cup, pooling. taste, softmax.
A copy of the previous image to help with the discussion

Dosing is another sampling of beans, and grinding functions as a way to flatten and homogenous the flavors in the bean.

Puck preparation convolves the particle sizes and shapes, and tamping acts to flatten the signal through compression.

Shot ratio is a way to cut the signal if we consider all the solubles the signal. We can limit how much of the solubles are pulled into the cup.

The cup itself is a pooling function of different extracts and flavors which lead to the final tasting.

The taste in itself is a softmax or output feature vector of flavors. The sum of these flavors is the taste of the cup, which is often very complex and the result of a process starting years, decades, or centuries before. To compare two coffees is done using a multidimension feature space (i.e., a flavor wheel).

Want to Connect?

If you like, follow me on Twitter, YouTube, and Instagram
where I post videos of espresso shots on different machines and
espresso-related stuff. You can also find me on LinkedIn.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Robert McKeon Aloe
Robert McKeon Aloe

Written by Robert McKeon Aloe

I’m in love with my Wife, my Kids, Espresso, Data Science, tomatoes, cooking, engineering, talking, family, Paris, and Italy, not necessarily in that order.

Responses (4)

Write a response