I am learning a VAE pytorch code. The dataset used is mnist. What the decoder outputs is,
**return** Independent(Normal(loc=x, scale = self.scale), 1)
So, the dimension of the output is a vector of 28 * 28 * batch_size
While, when it calculates the first term of ELBO, it uses log_prob,
p_x_given_z = self.decoder(z)
reconstruct_loss = -p_x_given_z.log_prob(x.view(shape[0], -1))
Now x_shape is a matrix of batch_size * (28 * 28), however, the p_x_given_z, the decoder output, is a vector of 28 * 28 * batch_size. The dimensions of both are different, how does the calculation work?