Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def gibsSampling(self, number_of_iterations):
counter = tf.constant(0)
[_, _, visible_cdstates] = control_flow_ops.while_loop(lambda count, num_iter, *args: count < num_iter,
self.singleStep, [counter, tf.constant(number_of_iterations), self._input])
# Stop tensorflow from propagating gradients back through the gibbs step
visible_cdstates = tf.stop_gradient(visible_cdstates)
return visible_cdstates
def callculate_state(self, probability):
return tf.floor(probability + tf.random_uniform(tf.shape(probability), 0, 1))
def singleStep(self, count, index, input_indexed):
hidden_states = self.callculate_state(tf.sigmoid(tf.matmul(input_indexed, self._weights) + self._hidden_bias))
visible_cdstates = self.callculate_state(tf.sigmoid(tf.matmul(hidden_states, tf.transpose(self._weights)) + self._visible_bias))
return count+1, index, visible_cdstates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment