summaryrefslogtreecommitdiff
path: root/models/layers.py
diff options
context:
space:
mode:
authorJordan Gong <jordan.gong@protonmail.com>2020-12-27 20:20:12 +0800
committerJordan Gong <jordan.gong@protonmail.com>2020-12-27 20:20:12 +0800
commit5a95c94e9f250001d0007b5ac238505d0a5f23b5 (patch)
tree3e997b6d45963ee7a035204d51b22a0c0a100a86 /models/layers.py
parent343e2311b48b900c07072849570f82a5b90d2aa7 (diff)
Refine auto-encoder
1. Wrap fully connected layers 2. Introduce hyperparameter tuning in constructor
Diffstat (limited to 'models/layers.py')
-rw-r--r--models/layers.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/models/layers.py b/models/layers.py
index cba6e47..f824078 100644
--- a/models/layers.py
+++ b/models/layers.py
@@ -83,6 +83,22 @@ class DCGANConvTranspose2d(BasicConvTranspose2d):
return super().forward(x)
+class BasicLinear(nn.Module):
+ def __init__(
+ self,
+ in_features: int,
+ out_features: int,
+ ):
+ super().__init__()
+ self.fc = nn.Linear(in_features, out_features, bias=False)
+ self.bn = nn.BatchNorm1d(out_features)
+
+ def forward(self, x):
+ x = self.fc(x)
+ x = self.bn(x)
+ return x
+
+
class FocalConv2d(BasicConv2d):
def __init__(
self,