I have implemented a Variational Autoencoder in Pytorch that works on SMILES strings(String representations of molecular structures).
When trained to output the same string as the input, the loss does not decrease between epochs.
I have tried removing the KL Divergence loss and sampling and training only the simple autoencoder. But, even this fails to converge.
Therefore I assume that the error must be with either the encoder, decoder or the training loop and probably is not related to the loss or sampling.
I have also tried the following unsuccessfully:

Addition of more GRU layers to improve learning capability of model.
Increasing and decreasing learning rate.
Changing the optimizer from Adam to SGD.
Modifying the batch size(increasing and decreasing)

The following is a link to my code:
https://colab.research.google.com/drive/1LctSm_Emnn5sHpw_Hon8xL5fF4bmKRw5 70
The following is a link to an equivalent( Same architecture) keras model that successfully trains.
https://colab.research.google.com/drive/170Peseik03CFYpWPNyD8B8mxUGxTQx67 23