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

水深无声 2023-02-18 14:15 112阅读 0赞

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

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

在def init(self, **kwargs)中

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

就可以了

发表评论

表情:
评论列表 (有 0 条评论,112人围观)

还没有评论,来说两句吧...

相关阅读