解决:Please use tf.compat.v1.Session instead.

环境:

  • tensorflow >=1.14

错误:

WARNING:tensorflow:From /Users/yuki//tf_test/test1.py:4: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

错误分析:

为了使TensorFlow在2.0版中更具简便性,TF 2.0设计上没有tf.Session。
TensorFlow 1.X要求用户通过调用tf。* API手动将抽象语法树(图形)拼接在一起。然后,它要求用户通过将一组输出张量和输入张量传递给session.run()调用来手动编译抽象语法树。
TensorFlow 2.0急切地执行(就像Python通常那样),在2.0中,图形和会话应该感觉像实现细节。
 

解决方式:

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

或者

tf.compat.v1.Session() as session

猜你喜欢

转载自blog.csdn.net/qq_19707521/article/details/105617708
今日推荐