All problems
VAE Reconstruction Loss
Problem
Compute the mean squared reconstruction error of a variational autoencoder: sum over elements of (x - x_hat)^2 divided by the number of elements.
The signature is vae_reconstruction_loss(x, x_hat).
Hint
Reconstruction terms are usually MSE or BCE; here use the mean squared error.
Test cases
case 1
in: [[1,2],[1,2]]
expected: 0
case 2
in: [[1,2],[0,0]]
expected: 2.5
case 3
in: [[0.5,0.5,0.5],[0,1,0]]
expected: 0.25
case 4
in: [[1,-1],[2,-1]]
expected: 0.5
Starter codePython
def vae_reconstruction_loss(x, x_hat):
# Your code here
pass4 test cases · run your code against them in the editor