Created
August 12, 2019 00:41
-
-
Save digantamisra98/3390c3117da6945902a156ccb00bf1f9 to your computer and use it in GitHub Desktop.
Basic PyTorch Sequential Model with Mish Activation Function
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
# Import Necessary Modules | |
from mish import Mish | |
import torch | |
from torch import nn | |
from collections import OrderedDict | |
# Initialize the activation function | |
activation_function = Mish() | |
#Define the Torch Model using nn.sequential | |
model = nn.Sequential(OrderedDict([ | |
('fc1', nn.Linear(784, 256)), | |
('activation', activation_function), | |
('fc2', nn.Linear(256, 128)), | |
('bn2', nn.BatchNorm1d(num_features=128)), | |
('activation_2', activation_function), | |
('dropout', nn.Dropout(0.3)), | |
('fc3', nn.Linear(128, 64)), | |
('bn3', nn.BatchNorm1d(num_features=64)), | |
('activation3', activation_function), | |
('logits', nn.Linear(64, 10)), | |
('logsoftmax', nn.LogSoftmax(dim=1))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment