(self, V)
| 90 | plt.show() |
| 91 | |
| 92 | def free_energy(self, V): |
| 93 | b = tf.reshape(self.b, (self.D, 1)) |
| 94 | first_term = -tf.matmul(V, b) |
| 95 | first_term = tf.reshape(first_term, (-1,)) |
| 96 | |
| 97 | second_term = -tf.reduce_sum( |
| 98 | # tf.log(1 + tf.exp(tf.matmul(V, self.W) + self.c)), |
| 99 | input_tensor=tf.nn.softplus(tf.matmul(V, self.W) + self.c), |
| 100 | axis=1 |
| 101 | ) |
| 102 | |
| 103 | return first_term + second_term |
| 104 | |
| 105 | def forward_hidden(self, X): |
| 106 | return tf.nn.sigmoid(tf.matmul(X, self.W) + self.c) |