Created
June 5, 2019 09:55
-
-
Save davidnvq/94a305570891ec7fc422b9886d378636 to your computer and use it in GitHub Desktop.
Test Dropout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
nn.Dropout(p=0.0).eval()(torch.ones(4, 10)) | |
"""Output | |
tensor([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]]) | |
""" | |
nn.Dropout(p=1.0)(torch.ones(4, 10)) | |
"""Output | |
tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]) | |
""" | |
nn.Dropout(p=0.0)(torch.ones(4, 10)) | |
"""Output | |
tensor([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], | |
[1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]]) | |
""" | |
nn.Dropout(p=0.5)(torch.ones(4, 10)) | |
"""Output | |
tensor([[2., 2., 0., 0., 0., 2., 0., 2., 2., 2.], | |
[0., 0., 2., 0., 2., 0., 0., 2., 2., 2.], | |
[2., 0., 2., 2., 0., 0., 2., 2., 2., 2.], | |
[2., 2., 2., 2., 0., 2., 0., 2., 2., 2.]]) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment