测试 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()

运行结果:

相关推荐
Lifangyun_WD2 分钟前
昇腾910B vs NVIDIA A100/H100:国产GPU算力租赁选型与迁移实践
人工智能·gpu算力·ai算力·算力租赁·gpu云主机
卡卡罗特AI6 分钟前
GPT5.6 今晚全量开发?Codex上线史上最强Coding模型!
人工智能·ai编程
某林2127 分钟前
从硬件解耦、3D公差设计到ROS 2柔性导航
人工智能·3d·机器人·ros2·技术复盘
字节跳动视频云技术团队12 分钟前
AI Agent 会自己选 CDN 了:当网站访问者从 “人” 扩展到 “AI”,内容分发已升级
人工智能·cdn
机器之心12 分钟前
世界模型太慢?西交大提出Fast LeWorldModel:用「动作前缀并行预测」让动态估计加速4倍
人工智能·openai
机器之心16 分钟前
今天,「空间原生」时代正式到来!
人工智能·openai
MicrosoftReactor19 分钟前
技术速递|Token 经济学:智能体 AI 时代的新 FinOps
人工智能·ai·agent·token·finops
阿里云大数据AI技术38 分钟前
AI Search × ES Agent Builder 最佳实践:企业智能助手落地指南
人工智能·elasticsearch
老白讲技术40 分钟前
2026年国内APP开发与软件定制服务商能力观察:从AI应用到行业系统开发
大数据·人工智能·ai·app·软件需求·app开发
项目经理老王1 小时前
OpenClaw免配置部署,开箱即用AI助手零门槛
人工智能