I take a look at keras/engine/training.py, and find that compile function do not need 3 arguments, so may be it's my version fault?
I simply change the line of code to
vae.compile(loss=None, optimizer='rmsprop')
Will this change do some harm or strange behavior?
My packages are listed below:
Python=2.7.13
Keras=2.1.2
tensorflow==1.4.1
tensorflow-gpu==1.4.1
There is a Keras blog post that references the code (2016), however the implementation is slightly different. The loss function implementation is different. I changed to this:
# Compute VAE loss
def vae_loss(x, x_decoded_mean):
xent_loss = original_dim * metrics.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)
return vae_loss
vae.compile(optimizer='rmsprop', loss=vae_loss)
EDIT: Updated with return from custom loss; seems to be compiling without issue now. Some other errors; look solvable.
@doujiang-zheng I removed the error by editing this:
vae.compile(optimizer='rmsprop', loss=None)
The loss is set to be None, because we are already adding the loss in the line:
vae.add_loss(vae_loss).
Hope this helps
Most helpful comment
@doujiang-zheng I removed the error by editing this:
vae.compile(optimizer='rmsprop', loss=None)The loss is set to be
None, because we are already adding the loss in the line:vae.add_loss(vae_loss).Hope this helps