Commit 43a3f956 by Ross Girshick

### bug fix in receptive field size calculations

parent 0ea4f8c2
 function out = receptive_field_size() % conv1 11 55x55 % conv2 27 55x55 % pool2 35 27x27 % conv3 51 27x27 % pool3 67 13x13 % conv4 99 13x13 % conv5 131 13x13 % pool5 163 6x6 out = ... pool3_to_conv3(... conv4_to_pool3(... conv5_to_conv4(... pool5_to_conv5(1)))); return out = ... conv1_to_input(... conv2_to_conv1(... pool2_to_conv2(... conv3_to_pool2(... pool3_to_conv3(... conv4_to_pool3(... conv5_to_conv4(... pool5_to_conv5(1)))))))); function out = pool5_to_conv5(p) out = 2*(p-1)+1 + 2*floor(3/2); function out = conv5_to_conv4(p) out = 1*(p-1)+1 + 2*floor(3/2); function out = conv4_to_pool3(p) out = 1*(p-1)+1 + 2*floor(3/2); function out = pool3_to_conv3(p) out = 2*(p-1)+1 + 2*floor(3/2); function out = conv3_to_pool2(p) out = 1*(p-1)+1 + 2*floor(3/2); function out = pool2_to_conv2(p) out = 2*(p-1)+1 + 2*floor(3/2); function out = conv2_to_conv1(p) out = 1*(p-1)+1 + 2*floor(5/2); function out = conv1_to_input(p) out = 4*(p-1)+1 + 2*floor(11/2);
 function receptive_field_sizes() % compute input size from a given output size f = @(output_size, ksize, stride) (output_size - 1) * stride + ksize; % fix the pool5 output size to 1 and derive the receptive field in the input out = ... f(f(f(f(f(f(f(f(1, 3, 2), ... % conv5 -> pool5 3, 1), ... % conv4 -> conv5 3, 1), ... % conv3 -> conv4 3, 1), ... % pool2 -> conv3 3, 2), ... % conv2 -> pool2 5, 1), ... % pool1 -> conv2 3, 2), ... % conv1 -> pool1 11, 4); % input -> conv1 fprintf('pool5 receptive field size: %d\n', out); out = ... f(f(f(f(f(f(f(1, 3, 1), ... % conv4 -> conv5 3, 1), ... % conv3 -> conv4 3, 1), ... % pool2 -> conv3 3, 2), ... % conv2 -> pool2 5, 1), ... % pool1 -> conv2 3, 2), ... % conv1 -> pool1 11, 4); % input -> conv1 fprintf('conv5 receptive field size: %d\n', out); out = ... f(f(f(f(f(f(1, 3, 1), ... % conv3 -> conv4 3, 1), ... % pool2 -> conv3 3, 2), ... % conv2 -> pool2 5, 1), ... % pool1 -> conv2 3, 2), ... % conv1 -> pool1 11, 4); % input -> conv1 fprintf('conv4 receptive field size: %d\n', out); out = ... f(f(f(f(f(1, 3, 1), ... % pool2 -> conv3 3, 2), ... % conv2 -> pool2 5, 1), ... % pool1 -> conv2 3, 2), ... % conv1 -> pool1 11, 4); % input -> conv1 fprintf('conv3 receptive field size: %d\n', out); out = ... f(f(f(f(1, 3, 2), ... % conv2 -> pool2 5, 1), ... % pool1 -> conv2 3, 2), ... % conv1 -> pool1 11, 4); % input -> conv1 fprintf('pool2 receptive field size: %d\n', out); out = ... f(f(f(1, 5, 1), ... % pool1 -> conv2 3, 2), ... % conv1 -> pool1 11, 4); % input -> conv1 fprintf('conv2 receptive field size: %d\n', out); out = ... f(f(1, 3, 2), ... % conv1 -> pool1 11, 4); % input -> conv1 fprintf('pool1 receptive field size: %d\n', out); out = ... f(1, 11, 4); % input -> conv1 fprintf('conv1 receptive field size: %d\n', out);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!