Hi all,
I have a question, I found a solution to brutforce the problem but that’s not very pretty coding. I was wondering if you had a better a solution for my following problem.
I have made a VAE that’s in the following form:
def forward(self, input):
    latent_vector = encoder(input)
    output = decoder(latent_vector)
    return output 

I actually have loss in the following form:
predicted = self.model(inputs).float()
loss = self.criterion(predicted, expected)
loss.backward()
self.optimizer.step()

I would like to force the latent vector to have a particular form, so I would like to add a term in the loss like:
loss = self.criterion(predicted, expected) + some_function(latent_vector)

Is there a proper way to get my latent vector to perform that ?
Best,
Didier