Exemplo n.º 1
0
    def test_token_error(self):
        ''' test token_error '''
        seq_list_one = [[5, 1, 1, 1, 1], [5, 2, 6, 10, 2]]
        seq_list_two = [[5, 2, 3, 1, 2], [5, 2, 6, 10, 2]]

        token_errors = metric_utils.token_error(seq_list_one,
                                                seq_list_two,
                                                eos_id=0)
        self.assertAllClose(token_errors, 0.3)
Exemplo n.º 2
0
 def call(self, y_true=None, y_pred=None, arguments=None):
   ''' compute metric '''
   eos_id = arguments['eos_id']
   return metric_utils.token_error(
       predict_seq_list=y_pred, target_seq_list=y_true, eos_id=eos_id)