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
评论列表
文章目录