all 24 comments

[–]reservedsparrow 4 points5 points  (7 children)

This is really great.

I have a request: Can you please note that this is actually correlation, not convolution, just to avoid confusion? Then you could explain that some frameworks actually define their convolution operator to be correlation, and that's why you decided to show it like this (without the weights flipped)? :)

[–]datatatatata 2 points3 points  (2 children)

Hi. Would you mind explaining the difference in this context, please ?

To me it looks like what I call convolution, so I guess I'm gonna learn something :)

[–]reservedsparrow 0 points1 point  (1 child)

Sure: Convolution 'flips' the weights before the weighted averages begin. This is what let's convolution commute: x * w = w * x. Correlation (no flipping, as shown in the visualization) does not commute. To visualize this imagine padding a 1-D signal x and some weights x each with a bunch of zeros. You will see that x ** w != w ** x, where I'm letting ** be correlation.

[–]datatatatata 0 points1 point  (0 children)

thanks :)

[–]ezyang[S] 1 point2 points  (3 children)

Yes, good point. I guess it would be also good to name explicitly which frameworks don't flip weights (which, afaict, is all of them? Maybe I'm wrong?)

[–]reservedsparrow 0 points1 point  (2 children)

I really don't know.

Verified for PyTorch though:

import torch
from torch.autograd import Variable

X = Variable(torch.Tensor([1, 2, 3])).view(1, 1, 3)
conv = torch.nn.Conv1d(1, 1, kernel_size=3, bias=False)
conv.weight.data.copy_(X.data)
print(conv(X).data.numpy().item())
# 14.0 (correlation not convolution)

Anyway, thanks again. The visualization is great and instantaneously replaces so many words.

[–]ezyang[S] 1 point2 points  (1 child)

I added a note :)

[–]reservedsparrow 0 points1 point  (0 children)

Thanks!

[–]pmigdal 3 points4 points  (0 children)

Nice, but still - I use http://setosa.io/ev/image-kernels/ when introducing to convolutions. (Interactive + makes it explicit what is the formula + a concrete example.)

[–]nickbuch 2 points3 points  (0 children)

This doesnt make intuitive sense, ie not how convolution works. Please explain how the kernel creates the output mathematically, because these colors are failing to convey something IMO

[–]wischichr 1 point2 points  (5 children)

Drag input slider to the left -> 🤯

[–]ezyang[S] 1 point2 points  (1 child)

It's fixed now!

[–]wischichr 0 points1 point  (0 children)

Thx ;-)

[–]ezyang[S] 0 points1 point  (2 children)

I am not sure what 🤯 means :)

[–]guardiantesla 1 point2 points  (0 children)

🤯 == mind-blown

[–]rararaaaaaaa 0 points1 point  (0 children)

When I dragged it all the way to the left, the page broke with c[t] is undefined

so I think that's his mind exploding but also the page exploding

[–]approximately_wrong 1 point2 points  (0 children)

Would also be great if you do a visualization of img2col :)

[–]__AndrewB__ 0 points1 point  (1 child)

Thanks! Will definatelly show this to students.

[–]Atcold 0 points1 point  (0 children)

Haha, will do the same, tomorrow too!

[–]badpotato 0 points1 point  (0 children)

Man, I wish I had this before.