Reputation: 1742
If I have the output shape, filter shape, strides and padding,
filter shape: [kernel_height, kernel_width, output_depth, input_depth]
output shape: [batch, height, width, depth]
strides=[1,1,1,1]
padding='VALID'
Can I get the input shape?
For example ,
filter shape: [3, 3, 1, 1]
output shape: [1, 1, 1, 1]
Can I compute the fixed input shape [1,3,3,1]
and How ?
Do you have the code to compute the shape? Because I think I need not to write it myself..
Upvotes: 1
Views: 426
Reputation: 12795
It's batch, height + kernel_height - 1, width + kernel_width - 1, input_depth
batch
at the beginning is somewhat obvious, so is input_depth
at the end. To understand height + kernel_height - 1
, consider how kernel is applied. If you input image was say 10 by 10 and you applied a 3 by 3 kernel, horizontally you would apply it at positions 0, 1, ..., 7, a total of 8 different positions, similar thinking applies to how kernel moves vertically, which would result in output map of size 8x8
. If you generalize this thinking, you will see that the size of the output map is width + kernel - 1, height + kernel - 1
, which means that if you have the size of the output map, to get the size of the input you need to invert the operation, which will result in width - kernel + 1, height - kernel + 1
.
This is all only valid for padding type "VALID". If the type was "SAME", the output would be padded to match the dimensions of the input, and as such the input shape would be batch, height, width, input_depht
Upvotes: 1