def test(self, model, num_ngrams, batch_size, num_batches):
        loss = 0.0
        for i in xrange(num_batches):
            ngram_start_id = i * batch_size
            ngram_end_id = (i + 1) * batch_size if i < (num_batches - 1) else num_ngrams
            sm_start_id, sm_end_id = io_read_ngram.get_sentence_matrix_range(self.test_set_x, ngram_start_id, ngram_end_id)
            loss -= model(ngram_start_id, ngram_end_id, sm_start_id, sm_end_id)  # model returns sum log likelihood
        loss /= num_ngrams
        perp = np.exp(loss)
        return (loss, perp)
Return average negative log-likelihood
dataset/ETHPy150Open yuhaozhang/nnjm-global/code/train_nnjm_gplus.py/TrainGlobalPlusModel.test