Solved by ptrblck in post #2 
              
              
                I’m not sure if both loss functions are equal. 
It seems the losses in Keras are averaged (I assumed divided by 2), while in PyTorch you are summing them. Both KL losses are multiplied by 0.5, but again in Keras you are using K.sum, while torch.mean in the PyTorch model. 
I’m not that familiar with …