Created
May 25, 2024 23:37
-
-
Save jgoodie/76bf6b98c0266620c35c2106afa2da94 to your computer and use it in GitHub Desktop.
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
# Build model | |
class IoTMultiClassModel(nn.Module): | |
def __init__(self, input_features=91, output_features=4, hidden_units=128, dropout=0.0): | |
super().__init__() | |
self.input_features = input_features | |
self.output_features = output_features | |
self.hidden_units = hidden_units | |
self.linear_layer_stack = nn.Sequential( | |
# 1 | |
nn.Linear(in_features=input_features, out_features=hidden_units), | |
nn.LeakyReLU(), # LeakyReLU | |
nn.Dropout(dropout), | |
# 2 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.LeakyReLU(), # LeakyReLU | |
nn.Dropout(dropout), | |
# 3 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.RReLU(), | |
nn.Dropout(dropout), | |
# 4 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.RReLU(), | |
nn.Dropout(dropout), | |
# 5 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.RReLU(), | |
nn.Dropout(dropout), | |
# 6 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.RReLU(), | |
nn.Dropout(dropout), | |
# 7 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.RReLU(), | |
nn.Dropout(dropout), | |
# 8 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.RReLU(), | |
nn.Dropout(dropout), | |
# 9 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.RReLU(), # RReLU | |
nn.Dropout(dropout), | |
# 10 | |
nn.Linear(in_features=hidden_units, out_features=hidden_units), | |
nn.LeakyReLU(), # RReLU | |
nn.Dropout(dropout), | |
# final | |
nn.Linear(in_features=hidden_units, out_features=output_features), | |
) | |
def forward(self, x): | |
return self.linear_layer_stack(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment