I am getting this error : mat1 and mat2 shapes cannot be multiplied (20x10 and 20x512)

latent_size = 20

encoder = ConditionalNormal(MLP(3000, latent_size,
hidden_units=[512,256],
activation=‘relu’,
in_lambda=lambda x: x.view(x.shape[0], 3000).float() - 1))
decoder = ConditionalNormal(MLP(latent_size, 3000,
hidden_units=[512,256],
activation=‘relu’,
out_lambda=lambda x: x.view(x.shape[0], 3000).float() - 1))

model = Flow(base_dist=StandardNormal((latent_size,)),
transforms=[
VAE(encoder=encoder, decoder=decoder)
]).to(device)

Hi,

Your code is pretty hard to read, you can use triple backticks ``` to nicely format it (like you would do on github).

And the error happens because the second dimension of the first matrix must match the first dimension of the second, but here you have 10 and 20. I guess you want to transpose the first matrix?

Hi Alban, sorry for this. Here is the updated code.

encoder = StandardNormal(MLP(3000, latent_size,
                                hidden_units=[512,256],
                                activation='relu',
                                x =  x.view(x.shape[0], 3000).float() - 1))
decoder = StandardNormal(MLP(latent_size, 3000,
                                   hidden_units=[512,256],
                                   activation='relu',
                                   x =  x.view(x.shape[0], 3000).float() - 1))

model = Flow(base_dist=StandardNormal((latent_size,)),
             transforms=[
                VAE(encoder=encoder, decoder=decoder)
             ]).to(device)

No I have input matrix to the encoder with 3000 dimensions and I want to get back the 3000 dimensions from the decoder.