New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conv1d and conv2d should support further batching #98
Comments
I think the DiffSharp implementations are consistent with https://pytorch.org/docs/stable/nn.functional.html#conv2d except the "groups" feature. We can revisit this. |
I'm currently working on 3d convolutions and then plan to move on to other essential operations in standard ML pipelines. I would like to finish that work before addressing this. |
right no rush with this |
Supporting 'further batching' should be a byproduct of implementing a reshape operation. The reshape operation should not add significant overhead as it just changes the shape. |
I investigated this further and I believe that this is not needed and we can close this issue. Details: This is how a regular 1d conv looks like in pytorch: import torch
x = torch.zeros(3,2,16, dtype=torch.float32) # input minibatch:3, in_channels: 2, size: 16
y = torch.zeros(5,2,3, dtype=torch.float32) # kernel out_channels: 5, in_channels: 2, size: 3
torch.nn.functional.conv1d(x,y).shape The result is
As @dsyme observed one could also use more than 3d tensors with this op, for example x = torch.zeros(3,2,10,16, dtype=torch.float32) # input minibatch:3, in_channels: 2, ?: 10, size: 16
y = torch.zeros(5,2,10,3, dtype=torch.float32) # kernel out_channels: 5, in_channels: 2, ?: 10, size: 3
torch.nn.functional.conv1d(x,y).shape which gives
or another example x = torch.zeros(3,2,10,20,16, dtype=torch.float32) # input minibatch:3, in_channels: 2, ?: 10, ?: 20, size: 16
y = torch.zeros(5,2,10,20,3, dtype=torch.float32) # kernel out_channels: 5, in_channels: 2, ?: 10, ?: 20, size: 3
torch.nn.functional.conv1d(x,y).shape which gives
The examples suggests that the first and second dimensions are still used as the minibatch and channel dimensions (not extra batch dimensions), the last dimension is still used as the data (e.g., image) dimension and any dimensions in between are somehow ignored in the output. This behavior is undocumented here and quite strange. I think we should not implement this and close the issue. I would support implementing it if it was documented in pytorch docs with an explanation of what it actually does. |
Closing this. Please ping me if there is something I missed and we can reopen. |
It looks like
conv1d
andconv2d
expect only one dimension of batching (NxCxI toconv1d
). In torch you can do additional dimensions of batching (N1xN2xCxI toconv1d
), compare:and
gives
The text was updated successfully, but these errors were encountered: