tensorflow 图理解

1
2
3
4
5
6
import tensorflow as tf

a = tf.constant(1, name="a")
b = tf.constant(2, name="b")
c = a + b
print(tf.get_default_graph().as_graph_def())
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
node {
name: "a"
op: "Const"
attr {
key: "dtype"
value {
type: DT_INT32
}
}
attr {
key: "value"
value {
tensor {
dtype: DT_INT32
tensor_shape {
}
int_val: 1
}
}
}
}
node {
name: "b"
op: "Const"
attr {
key: "dtype"
value {
type: DT_INT32
}
}
attr {
key: "value"
value {
tensor {
dtype: DT_INT32
tensor_shape {
}
int_val: 2
}
}
}
}
node {
name: "add"
op: "Add"
input: "a"
input: "b"
attr {
key: "T"
value {
type: DT_INT32
}
}
}
versions {
producer: 27
}
请作者喝一杯咖啡☕️