It looks like you solved it already but the reason this happens is the dropout layer adding some randomness. The dropout could be “turned off” to make the model deterministic with rnn.train(False) in the sample function.