TypeError: Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ref(

报错:TypeError: Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ref() as the key.
`这是tensorflow版本的问题,tensorflow改版后,从V1到V2,很多的东西变化了,导致用V1写的代码,在V2的框架下会报错。
这个报错的解决办法:

import tensorflow as tf
tf.compat.v1.disable_v2_behavior()

在def init(self, **kwargs)中

self.sess=tf.compat.v1.keras.backend.get_session()

就可以了

猜你喜欢

转载自blog.csdn.net/lingchuxiao/article/details/106825973