Unverified Commit 8fadb6ed authored by Andy Craze's avatar Andy Craze Committed by GitHub
Browse files

Update VariationalAutoencoder.py (#5049)

Add axis=1 for to reconstruction error calculation. This will avoid taking the sum of cost so that the training objective will no longer be  batch-size dependent.

Fixes #2243
parent d10aaacb
...@@ -21,7 +21,7 @@ class VariationalAutoencoder(object): ...@@ -21,7 +21,7 @@ class VariationalAutoencoder(object):
self.reconstruction = tf.add(tf.matmul(self.z, self.weights['w2']), self.weights['b2']) self.reconstruction = tf.add(tf.matmul(self.z, self.weights['w2']), self.weights['b2'])
# cost # cost
reconstr_loss = 0.5 * tf.reduce_sum(tf.pow(tf.subtract(self.reconstruction, self.x), 2.0)) reconstr_loss = 0.5 * tf.reduce_sum(tf.pow(tf.subtract(self.reconstruction, self.x), 2.0), 1)
latent_loss = -0.5 * tf.reduce_sum(1 + self.z_log_sigma_sq latent_loss = -0.5 * tf.reduce_sum(1 + self.z_log_sigma_sq
- tf.square(self.z_mean) - tf.square(self.z_mean)
- tf.exp(self.z_log_sigma_sq), 1) - tf.exp(self.z_log_sigma_sq), 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment