nn.CrossEntropyLoss expects targets passed as a LongTensor containing class indices, as it’s usually used for multi-class classification use cases.
I’m not sure, how your input tensor is defined, but I assume it contains float values.
In this case, you won’t be able to use nn.CrossEntropyLoss to reconstruct the input tensor.
Was the mentioned loss function from the VAE implementation not working?