| 31 | return z_mean,z_log_var |
| 32 | |
| 33 | class Decoder(torch.nn.Module): |
| 34 | def __init__(self,hidden_dim = 256,latent_dim = 2,num_features = 784): |
| 35 | super(Decoder, self).__init__() |
| 36 | self.initial_dense = torch.nn.Sequential( |
| 37 | torch.nn.Linear(in_features=latent_dim,out_features=hidden_dim), |
| 38 | torch.nn.ReLU(inplace=True), |
| 39 | |
| 40 | torch.nn.Linear(in_features=hidden_dim,out_features=hidden_dim * 2), |
| 41 | torch.nn.ReLU(inplace=True) |
| 42 | ) |
| 43 | |
| 44 | self.imgs = torch.nn.Linear(in_features=hidden_dim * 2,out_features=num_features) |
| 45 | |
| 46 | def forward(self,x): |
| 47 | x = self.initial_dense(x) |
| 48 | imgs = self.imgs(x) |
| 49 | imgs = imgs.view(-1,28,28) |
| 50 | return imgs |
| 51 | |
| 52 | |
| 53 | if __name__ == '__main__': |
no outgoing calls
no test coverage detected