1. 程式人生 > >tensorflow-計算圖(1)

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)為另一個計算圖