-
-
Save FrancescoSaverioZuppichini/8c4f3c06b304ca6eb2739987bed236f7 to your computer and use it in GitHub Desktop.
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
class MyCNNClassifier(nn.Module): | |
def __init__(self, in_c, n_classes): | |
super().__init__() | |
self.enc_sizes = [in_c, 32, 64] | |
conv_blocks = [conv_block(in_f, out_f, kernel_size=3, padding=1) | |
for in_f, out_f in zip(self.enc_sizes, self.enc_sizes[1:])] | |
self.encoder = nn.Sequential(*conv_blocks) | |
self.decoder = nn.Sequential( | |
nn.Linear(32 * 28 * 28, 1024), | |
nn.Sigmoid(), | |
nn.Linear(1024, n_classes) | |
) | |
def forward(self, x): | |
x = self.encoder(x) | |
x = x.view(x.size(0), -1) # flat | |
x = self.decoder(x) | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment