Created
October 20, 2019 06:35
-
-
Save Niranjankumar-c/49ec04404eea151c119b6078e1ebde57 to your computer and use it in GitHub Desktop.
model for visualizing dropout
This file contains 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
#create a neural network with out dropout | |
N_h = 100 #hidden nodes | |
model = torch.nn.Sequential( | |
nn.Linear(1, N_h), | |
nn.ReLU(), | |
nn.Linear(N_h, N_h), | |
nn.ReLU(), | |
nn.Linear(N_h, 1) | |
) | |
#create a network with dropout | |
model_dropout = nn.Sequential( | |
nn.Linear(1, N_h), | |
nn.Dropout(0.5), #50 % probability | |
nn.ReLU(), | |
torch.nn.Linear(N_h, N_h), | |
torch.nn.Dropout(0.2), #20% probability | |
torch.nn.ReLU(), | |
torch.nn.Linear(N_h, 1), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment