Data Science Workshop Dev
?
打印常量hello tensorflowimport tensorflow as tf tf.__version__ '2.4.0'
# 定义常量 hello_tf_constant = tf.constant("hello,tensorflow")
# 版本不兼容,无法直接运行 with tf.Session() as sess: sess.run(hello_tf_constant) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) ipython-input-3-4eb9d4d3287a in module ---- 1 with tf.Session() as sess: 2 sess.run(hello_tf_constant) AttributeError: module 'tensorflow' has no attribute 'Session'
with tf.compat.v1.Session() as sess: sess.run(hello_tf_constant) --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) ipython-input-4-420f364e899d in module 1 with tf.compat.v1.Session() as sess: ---- 2 sess.run(hello_tf_constant) /opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata) 966 try: 967 result = self._run(None, fetches, feed_dict, options_ptr, -- 968 run_metadata_ptr) 969 if run_metadata: 970 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) /opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1114 raise RuntimeError('Attempted to use a closed Session.') 1115 if self.graph.version == 0: - 1116 raise RuntimeError('The Session graph is empty. Add operations to the ' 1117 'graph before calling run().') 1118 RuntimeError: The Session graph is empty. Add operations to the graph before calling run().
tf.compat.v1.disable_eager_execution() with tf.compat.v1.Session() as sess: sess.run(hello_tf_constant) --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) ipython-input-5-95efe77ef2e2 in module 1 tf.compat.v1.disable_eager_execution() 2 with tf.compat.v1.Session() as sess: ---- 3 sess.run(hello_tf_constant) /opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata) 966 try: 967 result = self._run(None, fetches, feed_dict, options_ptr, -- 968 run_metadata_ptr) 969 if run_metadata: 970 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) /opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1114 raise RuntimeError('Attempted to use a closed Session.') 1115 if self.graph.version == 0: - 1116 raise RuntimeError('The Session graph is empty. Add operations to the ' 1117 'graph before calling run().') 1118 RuntimeError: The Session graph is empty. Add operations to the graph before calling run().
tf.compat.v1.disable_eager_execution() hello_tf_constant = tf.constant("hello,tensorflow") with tf.compat.v1.Session() as sess: print(sess.run(hello_tf_constant)) b'hello,tensorflow'
?
参考链接RuntimeError: The Session graph is empty. Add operations to the graph before calling run().解决方法AttributeError: module 'tensorflow' has no attribute 'Session'错误解决tensorflow 无法执行sess =tf .Session ()?
相关链接阿里云人工智能助理工程师认证(ACA)阿里云 天池?
备注工匠精神,精益求精,踏实学习,再接再厉 O(∩_∩)O
欢迎各位同学一起来交流学习心得!
作者:朱永生 什么是企业搜索 企业搜索,顾名思义,就是企业使用的搜索服务或者...
diff --git ... content of patch 邮件头中的?Subject:?字段是邮件标题 使用?[PA...
前言 今天说Java模块内容:反射。 反射介绍 正常情况下,我们知晓我们要操作的类...
前言 ThreadLocal的文章在网上也有不少,但是看了一些后,理解起来总感觉有绕,...
测试框架中参数化的一般形式 在Junit4和TestNG框架中实现参数化的形式几乎是一致...
公司介绍 深圳赛盒科技有限公司(IrobotBox)是一家以高科技创意为核心的技术服...
本文已经过原作者 Fernando Doglio 授权翻译。 并不是说 JS 的类有问题,但是如...
想要理解Spring,必须要掌握的两个知识点就是IoC和AOP,在这里我首先带大家了解...
Logic Gate公司首席执行官Matt Kunkel着眼于风险技术的下一个前沿,因为传统治理...
什么是数据可视化 数据可视化是数据内在价值的最终呈现手段,它利用各类图表及图...