Coder Social home page Coder Social logo

conv_arithmetic's Introduction

Convolution arithmetic

A technical report on convolution arithmetic in the context of deep learning.

The code and the images of this tutorial are free to use as regulated by the licence and subject to proper attribution:

Convolution animations

N.B.: Blue maps are inputs, and cyan maps are outputs.

No padding, no strides Arbitrary padding, no strides Half padding, no strides Full padding, no strides
No padding, strides Padding, strides Padding, strides (odd)

Transposed convolution animations

N.B.: Blue maps are inputs, and cyan maps are outputs.

No padding, no strides, transposed Arbitrary padding, no strides, transposed Half padding, no strides, transposed Full padding, no strides, transposed
No padding, strides, transposed Padding, strides, transposed Padding, strides, transposed (odd)

Dilated convolution animations

N.B.: Blue maps are inputs, and cyan maps are outputs.

No padding, no stride, dilation

Generating the Makefile

From the repository's root directory:

$ ./bin/generate_makefile

Generating the animations

From the repository's root directory:

$ make all_animations

The animations will be output to the gif directory. Individual animation steps will be output in PDF format to the pdf directory and in PNG format to the png directory.

Compiling the document

From the repository's root directory:

$ make

conv_arithmetic's People

Contributors

fvisin avatar vdumoulin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

conv_arithmetic's Issues

make error

make all_animations fails on Ubuntu Linux 14.04 as follows:

./bin/produce_figure arithmetic no_padding_no_strides 0 --input-size=4 --output-size=2 --padding=0 --kernel-size=3 --stride=1 
Traceback (most recent call last):
  File "./bin/produce_figure", line 272, in <module>
    compile_figure(which_, name, step, **args_dict)
  File "./bin/produce_figure", line 223, in compile_figure
    if '! LaTeX Error' in stdoutdata or '! Emergency stop' in stdoutdata:
TypeError: a bytes-like object is required, not 'str'
make: *** [pdf/no_padding_no_strides_00.pdf] Error 1

Misleading README license statement

The line, "The code and/or the images of this tutorial are free to use for non-commercial purposes with proper attribution:" in the README suggests that the same is not true for commercial purposes, but the MIT license permits commercial use.

Code run

Helllo, I'm a windows user. I want to know how to run the program. Please give a detailed introduce. Thank you!

clarify the kernel

Thanks for the great tutorial. The paper is informative and the animation is intuitive.

I would like to point out the kernel used in the deconvolution is not the same as the one used in the corresponding convolution, the former is a double-flipped version of the latter. For example, if the kernel used in the convolution is a 2x3 matrix [1,2,3; 4,5,6], i.e. first row is [1,2,3], and second row is [4,5,6], then the kernel used in the deconvolution is a double-flipped 2x3 matrix, (first flip along row-axis, then flip along column-axis). This results in [6,5,4;3,2,1], i.e. first row is [6,5,4], second row is [3,2,1].

If you agree with this, it would be nice to state it in the paper so that readers won't be confused.

Again, this is a great tutorial and I really appreciate it.

How to run the project?

when i try to do "make all_animations" from the repository's root directory,
there is an error
(env_shan) Arithmetic@qingjiaowosuanshujiadeMacBook-Pro conv_arithmetic-master % make all_animations
convert -density 600 pdf/numerical_no_padding_no_strides_00.pdf -flatten -resize 25% png/numerical_no_padding_no_strides_00.png
make: convert: No such file or directory
make: *** [png/numerical_no_padding_no_strides_00.png] Error 1

the readme can't help me ,is there any one can fix it or give me some advice?
thx

Error in Figure 4.7 (Page 27) Description?

Thanks guys for this amazing report, it helped me a lot in understanding convolutional arithmetic.

I think I found a slight error in the description of the figure 4.7 description on page 27 (line 3). Straight from the report:

The transpose of convolving a $3 \times 3$ kernel over a $6 \times 6$ input padded with a $1 \times 1$ border of zeros using $2 \times 2$ strides (i.e., $i = 6$, $k = 3$, $s = 2$ and $p = 1$). It is equivalent to convolving a $3 \times 3$ kernel over a 2 \times 2 input (with $1$ zero inserted between inputs) padded with a $1 \times 1$ border of zeros (with an additional border of size $1$ added to the bottom and right edges) using unit strides (i.e., $i' = 3$, $\tilde{i}' = 5$, $a = 1$, $k' = k$, $s' = 1$ and $p' = 1$).

Shouldn't this be 3 \times 3 ? The visual is probably correct, this feels erroneous, and can be seen by calculating directly from the formula of the direct convolution.

Possible minor error in sentence: "zero padding" -> "padding"

In the second last sentence of section 2.2 we have:

In practice, two specific instances of zero padding are used quite extensively because of their respective properties.

I suspect it should be:

"In practice, two specific instances of zero padding are used quite extensively because of their respective properties."

Edit:
The fist section of chapter 3 states:

Since pooling does not involve zero padding, the relationship describing the general case is as follows:

I think this should also be:

"Since pooling does not involve zero padding, the relationship describing the general case is as follows:"

or maybe "non-zero" padding?

or maybe:

"Since pooling only involves zero padding, the relationship describing the general case is as follows:"

In line 543 at the arithmetic.tex file, seems a typo here.

Hi, Dumoulin,

Thanks for your beautiful work first.

Seems I found a small typo inside the tex file.

In 543 line at the .tex file, inside the bracket, that's the original content:

To factor in zero padding (i.e., only restricting to $s = 0$),

I think the idea you want to show should be s = 1, either consider about the practical moving or the relationship below:

For any $i$, $k$ and $p$, and for $s = 1$,

Wish it is correct.

make error

I hit the following make error after downloading and doing ./bin/generate_makefile

jeremy@jeremy-TECRA-Z40-C:~conv_arithmetic$ make all_animations
./bin/produce_figure arithmetic no_padding_no_strides 0 --input-size=4 --output-size=2 --padding=0 --kernel-size=3 --stride=1 
Traceback (most recent call last):
  File "./bin/produce_figure", line 272, in <module>
    compile_figure(which_, name, step, **args_dict)
  File "./bin/produce_figure", line 223, in compile_figure
    if '! LaTeX Error' in stdoutdata or '! Emergency stop' in stdoutdata:
TypeError: a bytes-like object is required, not 'str'
Makefile:98: recipe for target 'pdf/no_padding_no_strides_00.pdf' failed
make: *** [pdf/no_padding_no_strides_00.pdf] Error 1

makefile looks like

conv_arithmetic.pdf : export BSTINPUTS=$BSTINPUTS:./natbib
conv_arithmetic.pdf : conv_arithmetic.tex
	pdflatex conv_arithmetic
	pdflatex conv_arithmetic
	bibtex conv_arithmetic
	pdflatex conv_arithmetic
	pdflatex conv_arithmetic

.PHONY : clean
clean : 
	rm -f conv_arithmetic.{aux,bbl,blg,log}

.PHONY : all_animations
all_animations : gif/no_padding_no_strides.gif gif/no_padding_no_strides_transposed.gif gif/arbitrary_padding_no_strides.gif gif/arbitrary_padding_no_strides_transposed.gif
 gif/same_padding_no_strides.gif gif/same_padding_no_strides_transposed.gif gif/full_padding_no_strides.gif gif/full_padding_no_strides_transposed.gif gif/no_padding_stride
s.gif gif/no_padding_strides_transposed.gif gif/padding_strides.gif gif/padding_strides_transposed.gif gif/padding_strides_odd.gif gif/padding_strides_odd_transposed.gif gi
f/dilation.gif gif/numerical_no_padding_no_strides.gif gif/numerical_padding_strides.gif gif/numerical_average_pooling.gif gif/numerical_max_pooling.gif

.SECONDARY : 

gif/no_padding_no_strides.gif : png/no_padding_no_strides_00.png png/no_padding_no_strides_01.png png/no_padding_no_strides_02.png png/no_padding_no_strides_03.png
	convert -delay 100 -loop 0 -layers Optimize +map -dispose previous $^ $@
	gifsicle --batch -O3 $@

gif/no_padding_no_strides_transposed.gif : png/no_padding_no_strides_transposed_00.png png/no_padding_no_strides_transposed_01.png png/no_padding_no_strides_transposed_02.p
ng png/no_padding_no_strides_transposed_03.png png/no_padding_no_strides_transposed_04.png png/no_padding_no_strides_transposed_05.png png/no_padding_no_strides_transposed_
06.png png/no_padding_no_strides_transposed_07.png png/no_padding_no_strides_transposed_08.png png/no_padding_no_strides_transposed_09.png png/no_padding_no_strides_transpo
sed_10.png png/no_padding_no_strides_transposed_11.png png/no_padding_no_strides_transposed_12.png png/no_padding_no_strides_transposed_13.png png/no_padding_no_strides_tra
nsposed_14.png png/no_padding_no_strides_transposed_15.png
	convert -delay 100 -loop 0 -layers Optimize +map -dispose previous $^ $@
	gifsicle --batch -O3 $@

gif/arbitrary_padding_no_strides.gif : png/arbitrary_padding_no_strides_00.png png/arbitrary_padding_no_strides_01.png png/arbitrary_padding_no_strides_02.png png/arbitrary
_padding_no_strides_03.png png/arbitrary_padding_no_strides_04.png png/arbitrary_padding_no_strides_05.png png/arbitrary_padding_no_strides_06.png png/arbitrary_padding_no_
strides_07.png png/arbitrary_padding_no_strides_08.png png/arbitrary_padding_no_strides_09.png png/arbitrary_padding_no_strides_10.png png/arbitrary_padding_no_strides_11.p
ng png/arbitrary_padding_no_strides_12.png png/arbitrary_padding_no_strides_13.png png/arbitrary_padding_no_strides_14.png png/arbitrary_padding_no_strides_15.png png/arbit
rary_padding_no_strides_16.png png/arbitrary_padding_no_strides_17.png png/arbitrary_padding_no_strides_18.png png/arbitrary_padding_no_strides_19.png png/arbitrary_padding
_no_strides_20.png png/arbitrary_padding_no_strides_21.png png/arbitrary_padding_no_strides_22.png png/arbitrary_padding_no_strides_23.png png/arbitrary_padding_no_strides_
24.png png/arbitrary_padding_no_strides_25.png png/arbitrary_padding_no_strides_26.png png/arbitrary_padding_no_strides_27.png png/arbitrary_padding_no_strides_28.png png/a
rbitrary_padding_no_strides_29.png png/arbitrary_padding_no_strides_30.png png/arbitrary_padding_no_strides_31.png png/arbitrary_padding_no_strides_32.png png/arbitrary_pad

....etc

Cyan?

The text says the feature maps are cyan and blue but the images show feature maps that are green and blue.

About Deconvnet Operation

Can anybody reveal the filtering process of deconvnet in the paper:

Visualizing and Understanding Convolutional Networks, arXiv:1311.2901v3

When I read the paper, I was confused by the filtering process of the deconvnet. They use the transpose of the same filter to convolute on the unpoolinged feature map.
It seems that the deconvolution process described in the paper is different from the process illustrated in this project.
Can anybody give a illustration on that or provide some addition material?
With thanks and regards!

Section 4.6

i' with a tilde is described but then i' is used in relationship 13.

Convolution algorithm

I understand your algorithm and implementation for 2d convolution using shift register based concept. Do you think this concept can be applied for 3d convolution ?

Readme miss labeling on transpose convolution input/output

I believe from the pdf that the cyan should be the input in the transposed convolution gifs, and the blue should be the output.

It should read:
N.B.: Blue maps are outputs, and cyan maps are inputs.

Please let me know if I'm interpreting the diagram wrong.

Figure 4.2 seems to have error

I am attaching the two figures taken from the arXiV. In convolution:
Screenshot 2021-10-06 at 6 17 42 PM
it says the padding is 2x2

and in transposed, it also says the padding is 2x2. Shouldn't it be 1x1?
Screenshot 2021-10-06 at 6 17 59 PM

Release arXiv version v2

Thanks for making this great guide! Its very useful and well written.

I am not sure if this is an error in the guide or a misunderstanding on my part.

Figures 2.1 through 2.4 are described as having "no stride" but then in the same sentence are described as having "unit strides" . It seems to me that "no stride" is not equivalent to "unit stride". IE: "no stride" should mean s=0 rather than s=1.

See image below.

image

What is input and what is output?

Hi! Great report :)

There is something confusing in gifs.
I can't distinguish (and probably nobody can) https://github.com/vdumoulin/conv_arithmetic/blob/master/gif/full_padding_no_strides_transposed.gif and https://github.com/vdumoulin/conv_arithmetic/blob/master/gif/no_padding_no_strides.gif (I'm not talking about width and height of feature map). You can't a priori tell what is up/down, input/output, before operation/after operation. I would suggest changing colors or (better) putting "input"/"output" labels.

Error in convolution computation

Aren't there mistakes in the images 1 to 8 for numerical_padding_strides-*.pdf ? For instance shouldn't the second element of the first row be 5 ?
Here is what is computed:

                   0 0 0 0 0 0 0                                               1 6 5
                   0 2 2 3 3 3 0                    Original result:           7 10 9
2 0 1              0 0 1 3 0 3 0                                               7 10 8
1 0 0     *        0 2 3 0 1 3 0       ---->
0 1 1              0 3 3 2 1 2 0                                               1 5 6
                   0 3 3 0 2 3 0                    My result:                 7 8 3
                   0 0 0 0 0 0 0                                               3 10 4

If I am correct then the mistakes are also on this website: http://deeplearning.net/software/theano/tutorial/conv_arithmetic.html

PS: Sorry for the chaotic display, can't figure it out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.