When specifying the contractive loss in an autoencoder according to the method given in the link:
https://wiseodd.github.io/techblog/2016/12/05/contractive-autoencoder/
Tensorflow 2.0 seems to be constantly throwing up errors. It says that we are giving a numpy input to a symbolic array or something. I ran the example in Google Colab and got the error. The Custom Loss function given in the link only worked when I set the following commands:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
I also tried to specify the custom reconstructive loss and KL loss for a VAE but I got the same error. It only worked when I copied the custom train_step from the Keras site. I tried the same procedure here but it didn't work. I got the error:
'KerasTensor' is missing attribute '_id'
I've heard that the issue may stem from eager execution in v2 but simply disabling eager execution in v2 doesn't seem to fix the error. Does anyone know how I can specify the custom loss without disabling v2 functionality?
question from:
https://stackoverflow.com/questions/65601953/why-does-tensorflow-2-give-errors-when-we-use-custom-loss-functions 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…