tensorflow-计算图(1)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 23 11:26:04 2018

@author: myhaspl
"""
import tensorflow as tf
#创建图
c=tf.constant(0.0)
g=tf.Graph()
with g.as_default():
    c1=tf.constant(0.1)
    print(c1.graph)
    print(g)
    print(c.graph)

<tensorflow.python.framework.ops.Graph object at 0xb1cd345c0>
<tensorflow.python.framework.ops.Graph object at 0xb1cd345c0>
<tensorflow.python.framework.ops.Graph object at 0x10d1f6160>
从输出可以看出
print(c1.graph)
print(g)
输出为同一个计算图,
而 print(c.graph)为另一个计算图

猜你喜欢

转载自blog.51cto.com/13959448/2334218