def certainty(self):
certainty = self.seg_prediction * tf.log(self.seg_prediction)
certainty = -tf.reduce_sum(certainty,reduction_indices=2)
s1 = tf.ones(tf.shape(certainty))
csum = tf.cumsum(s1,axis=1)
mask = tf.less_equal(csum,tf.cast(tf.tile(tf.expand_dims(self._length,1),[1,tf.shape(certainty)[1]]),tf.float32))
mask = tf.select(mask, tf.ones(tf.shape(certainty)),
tf.zeros(tf.shape(certainty)))
certainty *= mask
certainty = tf.reduce_sum(certainty, reduction_indices=1)
return certainty
评论列表
文章目录