bleu_score.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:master-thesis 作者: AndreasMadsen 项目源码 文件源码
def _build_metric(self, model: 'code.model.abstract.Model') -> tf.Tensor:
        # predownload datasets
        with NLTKEnv() as nltk_env:
            nltk_env.download('perluniprops')
            nltk_env.download('nonbreaking_prefixes')

        with tf.name_scope(None, self.metric_name,
                           values=[self.dataset.source,
                                   self.dataset.target, self.dataset.length]):
            predicted = model.inference_model(
                self.dataset.source, self.dataset.length, reuse=True
            )

            bleu = tf.py_func(self._py_implementaton,
                              [predicted, self.dataset.target],
                              tf.float32,
                              stateful=False,
                              name='nltk-corpus-bleu')
            return bleu
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号