def eval_pp(net, z, zt): """ Evaluate the perplexity of net z: training dictionary zt: testing dictionary """ if net.name != 'lbl': Im = zt['IM'] else: Im = None pp = lm_tools.perplexity(net, zt['ngrams'], z['word_dict'], Im=Im, context=net.context) print 'PERPLEXITY: ' + str(pp)
def compute_pp(self, Xp, word_dict): """ Compute the model perplexity """ return lm_tools.perplexity(self, Xp, word_dict, context=self.context)