Skip to content

Commit

Permalink
Update vae_keras.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bojone authored Jun 10, 2019
1 parent dd3e582 commit 5986f27
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions vae_keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from keras.layers import Input, Dense, Lambda
from keras.models import Model
from keras import backend as K
from keras import metrics
from keras.datasets import mnist


Expand Down Expand Up @@ -63,7 +62,7 @@ def sampling(args):
vae = Model(x, x_decoded_mean)

# xent_loss是重构loss,kl_loss是KL loss
xent_loss = original_dim * metrics.binary_crossentropy(x, x_decoded_mean)
xent_loss = original_dim * K.binary_crossentropy(x, x_decoded_mean)
kl_loss = - 0.5 * K.sum(1 + z_log_var - K.square(z_mean) - K.exp(z_log_var), axis=-1)
vae_loss = K.mean(xent_loss + kl_loss)

Expand Down

0 comments on commit 5986f27

Please sign in to comment.