测试 tensorflow 1.x 的一个demo 01

tensorflow 1.0的示例代码

demo_01.py

python 复制代码
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

def tf114_demo():
        a = 3
        b = 4
        c = a + b
        print("a + b in py =",c)
        a_t = tf.constant(3)
        b_t = tf.constant(4)
        c_t = a_t + b_t
        print("TensorFlow add a_t + b_t =", c_t)
        with tf.Session() as sess:
                c_t_value = sess.run(c_t)
                print("c_t_value= ", c_t_value)

        return None

def graph_demo():
        a_t = tf.constant(3)
        b_t = tf.constant(4)
        c_t = a_t + b_t
        print("TensorFlow add a_t + b_t =", c_t)
        default_g = tf.get_default_graph()
        print("default_g:\n",default_g)
        print("a_t g:", a_t.graph)
        print("c_t g:", c_t.graph)
        with tf.Session() as sess:
                c_t_value = sess.run(c_t)
                print("c_t_value= ", c_t_value)
                print("sess g:", sess.graph)
        return None



if __name__ == "__main__":
#       tf114_demo()
        graph_demo()

运行结果:

相关推荐
麦豆GEO14 分钟前
本地生活同城服务如何做好GEO优化
人工智能·生活
邂逅and回眸20 分钟前
具身智能入门:机器人是怎么学会干活的
人工智能·机器人
阿里云大数据AI技术1 小时前
SENSER识季 × 阿里云OpenSearch:从时尚灵感到自我表达
人工智能
the3clipse1 小时前
Windows 11 26H2 AI 功能使用指南:回顾、单击以执行与实时字幕
人工智能·windows·copilot+ pc·recall 回顾·单击以执行·实时字幕翻译·windows studio
OpenPie丨拓数派2 小时前
拓数派以产品化FDE基座赋能某世界500强医疗科技企业,打造基于本体论的DRG检验医保合规AI原生服务
人工智能
阿里云大数据AI技术3 小时前
Hologres 数据沙箱:让 AI 在隔离环境中安全探索和验证
人工智能
程序员cxuan3 小时前
Running Hub 上线 Motion
人工智能·aigc
高洁013 小时前
具身智能的人机协作与物理空间安全
人工智能·python·深度学习·机器学习·django
赛博山人4 小时前
Sand.ai发布MAGI-2视频模型
人工智能·音视频
橙序员小站4 小时前
下次放假还有几天?AI开发微信小程序复盘
人工智能·微信小程序