首页
学习
活动
专区
圈层
工具
发布
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    tf.Graph().as_default()

    tf.Graph().as_default() 表示将这个类实例,也就是新生成的图作为整个 tensorflow 运行环境的默认图,如果只有一个主线程不写也没有关系,tensorflow 里面已经存好了一张默认图...,可以使用tf.get_default_graph()来调用(显示这张默认纸),当你有多个线程就可以创造多个tf.Graph(),就是你可以有一个画图本,有很多张图纸,这时候就会有一个默认图的概念了。...具体的示例代码如下,和图中的一样: import tensorflow as tf c=tf.constant(4.0) assert c.graph is tf.get_default_graph(...) #看看主程序中新建的一个变量是不是在默认图里 g=tf.Graph() with g.as_default(): c=tf.constant(30.0) assert c.graph...(): c1 = tf.constant(4.0) g2 = tf.Graph() with g2.as_default(): c2 = tf.constant(20.0) with

    2.1K10
    领券