BIG clean up and refactoring
This commit is contained in:
1 parent
a905c0b094
commit
e7a579d720
24 files changed
+369
-597
No files matched your search
@@ -15,7 +15,7 @@ class LitModel(pl.LightningModule):
|
||||
if hparams:
|
||||
self.save_hyperparameters(hparams)
|
||||
|
||||
self.model = SimpleMNISTClassifier(config=self.hparams)
|
||||
self.model = SimpleMNISTClassifier(hparams=self.hparams)
|
||||
|
||||
def forward(self, x):
|
||||
return self.model(x)
|
||||
|
||||
@@ -3,24 +3,24 @@ from torch import nn
|
||||
|
||||
class SimpleMNISTClassifier(nn.Module):
|
||||
|
||||
def __init__(self, config):
|
||||
def __init__(self, hparams):
|
||||
super().__init__()
|
||||
|
||||
# mnist images are (1, 28, 28) (channels, width, height)
|
||||
self.model = nn.Sequential(
|
||||
nn.Linear(config["input_size"], config["lin1_size"]),
|
||||
nn.BatchNorm1d(config["lin1_size"]),
|
||||
nn.Linear(hparams["input_size"], hparams["lin1_size"]),
|
||||
nn.BatchNorm1d(hparams["lin1_size"]),
|
||||
nn.ReLU(),
|
||||
nn.Dropout(p=0.3),
|
||||
nn.Linear(config["lin1_size"], config["lin2_size"]),
|
||||
nn.BatchNorm1d(config["lin2_size"]),
|
||||
nn.Linear(hparams["lin1_size"], hparams["lin2_size"]),
|
||||
nn.BatchNorm1d(hparams["lin2_size"]),
|
||||
nn.ReLU(),
|
||||
nn.Dropout(p=0.25),
|
||||
nn.Linear(config["lin2_size"], config["lin3_size"]),
|
||||
nn.BatchNorm1d(config["lin3_size"]),
|
||||
nn.Linear(hparams["lin2_size"], hparams["lin3_size"]),
|
||||
nn.BatchNorm1d(hparams["lin3_size"]),
|
||||
nn.ReLU(),
|
||||
nn.Dropout(p=0.2),
|
||||
nn.Linear(config["lin3_size"], config["output_size"]),
|
||||
nn.Linear(hparams["lin3_size"], hparams["output_size"]),
|
||||
nn.LogSoftmax(dim=1)
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user