New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tensorflow.keras behaves wrongly in autoencoder setup compared to keras #39432
Comments
It seems like the problem may lie with autoencoder.compile(optimizer='adam', loss='binary_crossentropy') Try using this instead for now. |
@fedxa |
@Saduf2019 Oh, yes! The difference is in the default learning rate for the The
whiel the
Initialising the optimiser explicitly with the same learning rate makes the example behave in the same way for both keras versions. Seems it is a feature, not a bug. |
@fedxa This has been clearly mentioned in the docs here More over the learning rate of all the optimizers have been set to 0.001. This is expected. |
@gowthamkpr Yes, for sure, missed this bit!
to
with |
@fedxa The algorithm is correct. The learning rate is contained within the term |
@iobtl Hmm, seems the actual code in tensorflow/python/keras/optimizers.py#L448 does not really correspond to Algorithm 1 in the paper, but is additionally multiplied by the learning rate. C.f. also line-by-line comparison https://stackoverflow.com/questions/56730888/what-is-the-learning-rate-parameter-in-adadelta-optimiser-for-in-keras |
Similar observation here. I believe it is related to the tf.keras.losses binary_crossentropy implementation. I have run 3 versions in Colab of the Keras VAE tutorial: Version 1 using Keras Version 1 and 3 converge, version 2 does not Results: Version 2: Version 3: Colab notebook: |
Looks like a separate problem for me... Mine was clearly the initial learning rate in AdaDelta optimizer. Yours looks like different binary_crossentropy realizations |
Hi, thanks for your message, it does look like a separate problem so I will open a different issue for it. |
@fedxa This is a stale issue. Now, Keras code moved to separate repo keras-team/keras and the code is same whether it is imported from Keras or tf.keras. Can we close this issue? Thanks! |
This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you. |
Closing as stale. Please reopen if you'd like to work on this further. |
Attempt to recreate the simplistic autoencoder works properly if keras (2.3.1) is used, but fails to converge if tensorflow.keras (2.3.0-tf).
The basic realisation can be found in https://gist.github.com/fedxa/45eb1a412964ddf19820fff347c5b2de
If the separate keras 2.3.1 is used -- the example converges fast, if the tensorflow.keras 2.3.0-tf is used no convergence is observed (loss funciton is ~0.6 all the time and autoencoder encodes noise only).
The problem is present in google collab, on linux and MacOS with tensorflow versions 2.0, 2.1, 2.2
The text was updated successfully, but these errors were encountered: