def gaussian_stochastic(self, input_tensor, num_maps, scope):
"""
:param inputs_list: list of Tensors to be added and input into the block
:return: random variable single draw, mean, standard deviation, and intermediate representation
"""
with tf.variable_scope(scope):
input_tensor = tf.expand_dims(tf.expand_dims(input_tensor, 1), 1) if len(input_tensor.get_shape()) != 4 \
else input_tensor
intermediate = slim.conv2d(input_tensor, self._hidden_size, [1, 1], weights_initializer=self._initializer,
scope='conv1')
mean = slim.conv2d(intermediate, num_maps, [1, 1], weights_initializer=self._initializer,
activation_fn=None, scope='mean')
sigma2 = tf.nn.softplus(
slim.conv2d(intermediate, num_maps, [1, 1], weights_initializer=self._initializer,
activation_fn=None, scope='sigma2'))
rv_single_draw = mean + tf.sqrt(sigma2) * tf.random_normal(tf.shape(mean))
self.split_labeled_unlabeled(mean, '{}_mu'.format(scope))
self.split_labeled_unlabeled(sigma2, '{}_sigma2'.format(scope))
self.split_labeled_unlabeled(rv_single_draw, '{}_sample'.format(scope))
return rv_single_draw
评论列表
文章目录