Created
December 4, 2018 00:28
-
-
Save albertlai431/32dfa2c870933bfedf7a6bbd5e358695 to your computer and use it in GitHub Desktop.
Initializing Layers
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
def __init__(self): | |
super(CNNModel, self).__init__() | |
#Convolution 1 | |
self.cnn1 = nn.Conv2d(in_channels=1, out_channels=16, kernel_size=5, stride=1, padding=2) | |
self.relu1 = nn.ReLU() | |
#Max pool 1 | |
self.maxpool1 = nn.MaxPool2d(kernel_size=2) | |
#Convolution 2 | |
self.cnn2 = nn.Conv2d(in_channels=16, out_channels=32, kernel_size=5, stride=1, padding=2) | |
self.relu2 = nn.ReLU() | |
#Max pool 2 | |
self.maxpool2 = nn.MaxPool2d(kernel_size=2) | |
#Dropout for regularization | |
self.dropout = nn.Dropout(p=0.5) | |
#Fully Connected 1 | |
self.fc1 = nn.Linear(32*7*7, 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment