# Which type auto encoder gives best results for text

I did I couple of examples for auto encoders for images and they worked fine. Now I want to do an auto encoder for text that takes as input a sentence and returns the same sentence. But when I try to use the same auto encoders as the ones I used for the images I get bad results.

I guess the reason for this is that my text is sparse and I have a big vocabulary size of 500K words.

1. Do you have a link of a working example of an auto encoder for text in Keras?

2. I saw that in most papers they use cross-entropy as a loss function. How does cross-entropy calculate the loss exactly ? Does it make sense to use cross-entropy even if I do a character by character auto encoder?

• Hi so I tried the code you suggested. I can generate text but I don't understand how the autoencoder works. What I want to do is to give some text as input and have the same text as output. But in this case when I do: pred = vae.predict(test, batch_size=500) pred contains only 1s. So it doesn't make sense. Am I doing something wrong ? – sspp Mar 29 '18 at 19:07