def error(self):
mistakes = tf.not_equal(
tf.argmax(self._target, 2), tf.argmax(self.prediction, 2))
mistakes = tf.cast(mistakes, tf.float32)
mask = tf.sign(tf.reduce_max(self._target, reduction_indices=2))
mistakes *= mask
# Average over actual sequence lengths.
mistakes = tf.reduce_sum(mistakes, reduction_indices=1)
mistakes /= tf.cast(self._length, tf.float32)
return tf.reduce_mean(mistakes)
评论列表
文章目录