Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference between dropout2d and dropout3d #22879

Open
kianasun opened this issue Jul 15, 2019 · 2 comments
Open

Difference between dropout2d and dropout3d #22879

kianasun opened this issue Jul 15, 2019 · 2 comments
Labels
module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@kianasun
Copy link
Contributor

馃悰 Bug

The difference between Dropout2d and Dropout3d is not clear. They use exactly same code but different documentation. As in the documentation of Dropout2d and Dropout3d, they should have different shapes of input, but it seems that they can work for inputs with other shape (dimension > 2). Should we just combine them (a generalized one)? Or at least restrict the input?

To Reproduce

torch.manual_seed(0)
m = nn.Dropout3d(p=0.2)
input = torch.randn(2, 2, 2)
output = m(input)
output
tensor([[[ 1.9262, -0.3668],
         [-2.7235,  0.7105]],

        [[-1.3557, -1.7482],
         [ 0.5042,  1.0475]]])

torch.manual_seed(0)
m = nn.Dropout2d(p=0.2)
input = torch.randn(2, 2, 2)
output = m(input)
output
tensor([[[ 1.9262, -0.3668],
         [-2.7235,  0.7105]],

        [[-1.3557, -1.7482],
         [ 0.5042,  1.0475]]])
@zou3519 zou3519 added better-engineering Relatively self-contained tasks for better engineering contributors triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: nn Related to torch.nn and removed better-engineering Relatively self-contained tasks for better engineering contributors labels Jul 16, 2019
@zou3519
Copy link
Contributor

zou3519 commented Jul 16, 2019

We should definitely at leastrestrict the input. Under the hood, Dropout2d and Dropout3d call the same function feature_dropout that interprets the input tensor as having batch dimension 0 and channel dimension 1. This means that sending a 5d batch of images (N0, N1, C, H, W) to Dropout2d is misleadingly incorrect.

@kianasun
Copy link
Contributor Author

@zou3519 Yes. If we simply want to restrict the input, maybe I can add some TORCH_CHECK. If we want to generalize it, we can just give some examples to show how it works in different situations, e.g. images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

2 participants