def noisy_and(self, num_classes, trainable=True):
""" Multiple Instance Learning (MIL), flexible pooling function
:param num_classes: int, determine number of output maps
"""
assert self.input.get_shape()[3] == num_classes # input tensor should have map depth equal to # of classes
scope = 'noisyAND'
with tf.variable_scope(scope):
a = self.const_variable(name='a', shape=[1], value=1.0, trainable=trainable)
b = self.const_variable(name='b', shape=[1, num_classes], value=0.0, trainable=trainable)
mean = tf.reduce_mean(self.input, axis=[1, 2])
self.input = (tf.nn.sigmoid(a * (mean - b)) - tf.nn.sigmoid(-a * b)) / (
tf.sigmoid(a * (1 - b)) - tf.sigmoid(-a * b))
print(scope + ' output: ' + str(self.input.get_shape()))
评论列表
文章目录