Skip to content

Instantly share code, notes, and snippets.

@ih4cku ih4cku/calc.py
Last active Jun 4, 2018

Embed
What would you like to do?
calc DeepLab receptive field
#!/usr/bin/env python
# net architecture of http://ccvl.stat.ucla.edu/ccvl/DeepLab/train.prototxt
# format: [kernel, stride]
deep_lab_vgg = [
# 1
[3, 1],
[3, 1],
[2, 2],
# 2
[3, 1],
[3, 1],
[2, 2],
# 3
[3, 1],
[3, 1],
[3, 1],
[2, 2],
# 4
[3, 1],
[3, 1],
[3, 1],
[2, 1],
# 5
[5, 1],
[5, 1],
[5, 1],
[3, 1],
# fc6, kernel=4, hole=4
[13, 1]
]
# K: composed kernel, also the receptive field
# S: composed stride
K, S = 1, 1
for i in range(len(deep_lab_vgg)):
k, s = deep_lab_vgg[i]
K = (k-1) * S + K
S = S * s
print 'layer:', i, deep_lab_vgg[i], '[', K, S, ']'
@luofanghao

This comment has been minimized.

Copy link

commented Jul 11, 2016

P.S.:
receptive filed of hole_conv:
r.f. = kernel + (kernel-1)*(hole-1)

@Jmq14

This comment has been minimized.

Copy link

commented Aug 30, 2016

Hi
The deeplab paper said "In the case of the VGG-16 net we consider, its receptive field is 224x224 (with zero-padding) and 404x404 pixels if the net is applied convolutionally" and "We have addressed this practical problem by spatially subsampling (by simple decimation) the first FC layer to 4x4 (or 3x3) spatial size. This has reduced the receptive field of the network down to 128x128 (with zero-padding) or 308x308 (in convolutional mode) "
How do they calculate and get the results of "224x224" and "128x128" ? What does "with zero-padding" mean? Zero-padding doesn't influence receptive field, does it?
I guess you guys might have answers. Thanks a lot!

@qivigor

This comment has been minimized.

Copy link

commented Jun 4, 2018

i have the same questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.