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

运行结果:

相关推荐
多恩Stone23 分钟前
【3DV 进阶-5】3D生成中 Inductive Bias (归纳偏置)的技术路线图
人工智能·python·算法·3d·aigc
HaiLang_IT24 分钟前
2026 人工智能与大数据专业毕业论文选题方向及题目示例(nlp/自然语言处理/图像处理)
大数据·人工智能·毕业设计选题
minhuan30 分钟前
构建AI智能体:八十二、潜藏秩序的发现:隐因子视角下的SVD推荐知识提取与机理阐释
人工智能·svd推荐·隐因子·推荐模型
封奚泽优1 小时前
Neo4j中导入.owl数据
知识图谱·neo4j·owl·rdf
Doro再努力1 小时前
Neo4j图数据库:简述增删改查
数据库·neo4j
Brianna Home1 小时前
大模型如何变身金融风控专家
人工智能·深度学习·机器学习·自然语言处理·stable diffusion·1024程序员节
HPC_C1 小时前
Efficient Memory Management for Large Language Model with PagedAttention
人工智能·语言模型·自然语言处理
维维180-3121-14551 小时前
ChatGPT-4o在自然科学中的应用:统计建模、机器学习与时空数据分析实战
人工智能·生态·环境·气象·农业
后端小肥肠1 小时前
从 Coze 到 n8n:我用 n8n 实现了10w+小林漫画的爆款流水线生产
人工智能·aigc·agent