Loading...
Calculate the spatial dimensions of a convolutional layer output.
The output size O of a convolutional layer is determined by input size I, filter size F, padding P, and stride S using the formula:
O=⌊SI−F+2P⌋+1
If the filter is larger than the padded input (i.e., I−F+2P<0), the configuration is invalid.
Write a function conv_output_size(input_size, filter_size, padding, stride) that returns the output dimension. If the configuration is invalid (filter larger than padded input), return -1.
Return an integer representing the output dimension, or -1 if invalid.
input_size=32, filter_size=3, padding=1, stride=1
32
floor((32 - 3 + 2*1) / 1) + 1 = floor(32/1) + 1 = 32