karpathy / char-rnn

Multi-layer Recurrent Neural Networks (LSTM, GRU, RNN) for character-level language models in Torch
11.59k stars 2.58k forks source link

Add script for perplexity and cross entropy #142

Closed EdenMacdonald closed 3 years ago

EdenMacdonald commented 8 years ago

Perplexity measurements are a useful way to evaluate the quality of a language model.

measure_perplexity.lua calculates the cross entropy and perplexity of a model (loaded from a checkpoint) relative to some test corpus. The calculations are done at both the character and the word level.

I think this script (or some similar script) could be useful for anyone who is interested in quantitatively comparing or ranking probabilistic language models.