gpt4 book ai didi

keras - 运行 Tensorflow 2.0 代码给出 'ValueError: tf.function-decorated function tried to create variables on non-first call' 。我究竟做错了什么?

转载 作者:行者123 更新时间:2023-12-01 18:00:07 32 4
gpt4 key购买 nike

error_giving_notebook

non_problematic_notebook

可以看出,我在“error_giving_notebook”中使用了 tf.function 装饰器,它会抛出 ValueError,而同一笔记本除了删除 tf.function 装饰器之外没有任何更改,可以在“non_problematic_notebook”中顺利运行。可能是什么原因?

最佳答案

当您尝试在 TF 2.0 中使用函数装饰器时,请在导入 TensorFlow 后使用以下行立即启用 run 函数:

tf.config.experimental_run_functions_eagerly(True)

由于上述内容已被弃用(不再是实验性的?),请使用以下内容:

tf.config.run_functions_eagerly(True)

如果您想了解更多信息,请参阅 this链接。

关于keras - 运行 Tensorflow 2.0 代码给出 'ValueError: tf.function-decorated function tried to create variables on non-first call' 。我究竟做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58352326/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com