Created
February 17, 2016 07:36
-
-
Save bearpaw/da4111eac4cbe077b29c to your computer and use it in GitHub Desktop.
Compute Receptive Field Size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conv1 5 1 | |
pool1 2 2 | |
conv2 5 1 | |
pool2 2 2 | |
conv3 5 1 | |
conv4 9 1 | |
conv5 1 1 | |
conv6 1 1 | |
conv7 9 1 | |
conv8 13 1 | |
conv9 13 1 | |
conv10 15 1 | |
conv11 1 1 | |
conv12 1 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
def recep_recur(output_size, ksize, stride): | |
return (output_size - 1) * stride + ksize | |
def print_receptive_fields(params): | |
for x in xrange(len(params)): | |
name, cur_ksize, cur_stride = params[x] | |
output_size = 1 | |
for reverse_iter in xrange(x, -1, -1): | |
__, ksize, stride = params[reverse_iter] | |
ksize, stride = int(ksize), int(stride) | |
output_size = recep_recur(output_size, ksize, stride) | |
print "{}:\trf={}\tksize={}\tstride={}".format( | |
name, output_size, int(cur_ksize), int(cur_stride)) | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('param_file', type=str, | |
help='''File containing kernel sizes and stride sizes | |
of each layer.''') | |
args = parser.parse_args() | |
params = [] | |
with open(args.param_file, 'r') as f: | |
for line in f: | |
# k_sizes = [int(i) for i in line.split()] | |
cur_param = line.split() | |
params.append(cur_param) | |
print_receptive_fields(params) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python receptive_fields.py demo.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment