def forward(self, x):
# define the forward computation on the image x
# first shape the mini-batch to have pixels in the rightmost dimension
x = x.view(-1, 784)
# then compute the hidden units
hidden = self.softplus(self.fc1(x))
# then return a mean vector and a (positive) square root covariance
# each of size batch_size x z_dim
z_mu = self.fc21(hidden)
z_sigma = torch.exp(self.fc22(hidden))
return z_mu, z_sigma
# define the PyTorch module that parameterizes the
# observation likelihood p(x|z)
评论列表
文章目录