Reputation: 831
Based on my understanding, CNN output size for 1D is
output_size = (input_size - kernel_size + 2*padding)//stride + 1
Refer to PyTorch DQN Tutorial. In the tutorial, it uses 0 padding, which is fine. However, it computes the output size as follows:
def conv2d_size_out(size, kernel_size = 5, stride = 2):
return (size - (kernel_size - 1) - 1) // stride + 1
It the above a mistake or is there something I missed?
Upvotes: 0
Views: 280
Reputation: 871
No, it's not a mistake because
size - (kernel_size - 1) - 1 = size - kernel_size + 2 * 0
with 0 as padding
(it's not code, its an equation sorry for the formatting)
I think the tutorial is using the formula for the output size from the official document which is
output_size = ((input_size + 2 * padding - dialation * (kernel_size - 1) - 1) // stride + 1
Upvotes: 2