Tivadar Danka Profile picture
Apr 13, 2021 9 tweets 3 min read Read on X
Convolution is not the easiest operation to understand: it involves functions, sums, and two moving parts.

However, there is an illuminating explanation — with probability theory!

There is a whole new aspect of convolution that you (probably) haven't seen before.

🧵 👇🏽
In machine learning, convolutions are most often applied for images, but to make our job easier, we shall take a step back and go to one dimension.

There, convolution is defined as below.
Now, let's forget about these formulas for a while, and talk about a simple probability distribution: we toss two 6-sided dices and study the resulting values.

To formalize the problem, let 𝑋 and 𝑌 be two random variables, describing the outcome of the first and second toss.
Just for fun, let's also assume that the dices are not fair, and they don't follow a uniform distribution.

The distributions might be completely different.

We only have a single condition: 𝑋 and 𝑌 are independent.
What is the distribution of the sum 𝑋 + 𝑌?

Let's see a simple example. What is the probability that the sum is 4?

That can happen in three ways:

𝑋 = 1 and 𝑌 = 3,
𝑋 = 2 and 𝑌 = 2,
𝑋 = 3 and 𝑌 = 1.
Since 𝑋 and 𝑌 are independent, the joint probability can be calculated by multiplying the individual probabilities together.

Moreover, the three possible ways are disjoint, so the probabilities can be summed up.
In the general case, the formula is the following.

(Don't worry about the index going from minus infinity to infinity. Except for a few terms, all others are zero, so they are eliminated.)

Is it getting familiar?
This is convolution.

We can immediately see this by denoting the individual distributions with 𝑓 and 𝑔.

The same explanation works when the random variables are continuous, or even multidimensional.

Only thing that is required is independence.
Even though images are not probability distributions, this viewpoint helps us make sense of the moving parts and the everyone-with-everyone sum.

If you would like to see an even simpler visualization, just think about this:

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Tivadar Danka

Tivadar Danka Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @TivadarDanka

Jun 8
Differentiation reveals much more than the slope of the tangent plane.

We like to think about it that way, but from a different angle, differentiation is the same as an approximation with a linear function. This allows us to greatly generalize the concept.

Let's see why! Image
By definition, the derivative of a function at the point 𝑎 is defined by the limit of the difference quotient, representing the rate of change. Image
In geometric terms, the differential quotient represents the slope of the line between two points of the function's graph. Image
Read 12 tweets
Jun 6
Most people see neural networks as magic.

But at their core, they’re just graphs. And those are built from math so simple, you learned it in high school.

Here’s how computational graphs make deep learning possible, and why they’re the real MVP of machine learning. Image
Representing graphs as matrices unlocked new discoveries in both CS and math.

Similarly, viewing neural networks as computational graphs unlocked modern ML.

The magic is in the representation. Image
At a macro level, a neural network is a composition of a sequence of functions:

N(x) = Softmax(Linear₁(Relu(Linear₂(x))))

At a micro level:

A graph of operations + variables.

• Each variable becomes a node.
• Each operation becomes an edge. Image
Read 6 tweets
Jun 4
This will surprise you: sine and cosine are orthogonal to each other.

What does orthogonality even mean for functions? In this thread, we'll use the superpower of abstraction to go far beyond our intuition.

We'll also revolutionize science on the way. Image
Our journey ahead has three milestones. We'll

1. generalize the concept of a vector,
2. show what angles really are,
3. and see what functions have to do with all this.

Here we go!
Let's start with vectors. On the plane, vectors are simply arrows.

The concept of angle is intuitive as well. According to Wikipedia, an angle “is the figure formed by two rays”.

How can we define this for functions? Image
Read 18 tweets
Jun 3
In machine learning, we use the dot product every day.

However, its definition is far from revealing. For instance, what does it have to do with similarity?

There is a beautiful geometric explanation behind. Image
By definition, the dot product (or inner product) of two vectors is defined by the sum of coordinate products. Image
To peek behind the curtain, there are three key properties that we have to understand.

First, the dot product is linear in both variables. This property is called bilinearity. Image
Read 15 tweets
May 7
Behold one of the mightiest tools in mathematics: the camel principle.

I am dead serious. Deep down, this tiny rule is the cog in many methods. Ones that you use every day.

Here is what it is, how it works, and why it is essential. Image
First, the story.

The old Arab passes away, leaving half of his fortune to his eldest son, third to his middle son, and ninth to his smallest.

Upon opening the stable, they realize that the old man had 17 camels. Image
This is a problem, as they cannot split 17 camels into 1/2, 1/3, and 1/9 without cutting some in half.

So, they turn to the wise neighbor for advice. Image
Read 18 tweets
Mar 22
I am Hungarian, living in Hungary for 35 years. Everything is government propaganda in this thread.

Let me provide all the context.

Learn from this, and maybe your country can succeed in stopping an authoritarian takeover, in which Hungary have failed.

"1. No income tax for women with at least two children for life."

This is an election hack, meant to buy votes for the upcoming 2026 election. Fidesz (Hungary's ruling party) is significantly down in the polls after it was leaked that a convicted p*d*ph*le accessory was given a presidential pardon.

Hell, they even let a child p*rn*gr*phy wholesaler with 96000 images on his computer walk away with ~$1500 fine. (Check en.wikipedia.org/wiki/G%C3%A1bo… if you don't believe me.)

Thus, the government is scraping to buy back the trust of families.

Even if it wasn't an empty promise, waiving the income tax is unrealistic for budgetary reasons. Hungary's economy is in the toilet.
"3. Housing incentives for young couples.

Offers a low interest loan for couples raising or committing to having one child or more."

This loan is another propaganda trick. In practice, this loan resulted in the biggest housing crisis of the country's history, because all it did was raise the price of every real estate by the amount of the loan, making real estate ownership virtually impossible for the young generation.
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(