- What is Data FLow Graph?
Graph : Node(정점)와 Edge(간선)로 연결된 것
data flow graph
하나의 operation
Edge는 data, Tensor
노드는 operation
Tensor가 돌아다닌다 하여
Tensorflow이다
- Example tensorflow v 2.4.0
HelloWorld.py
1
2
3
4
5
6
7
8
|
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
hello = tf.constant('Hello, Tensorflow!')
print(hello)
|
cs |
Computertational_Graph.py
-1
1
2
3
4
5
6
7
8
9
10
11
12
|
import tensorflow as tf
import numpy as np
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
node3 = tf.add(node1, node2)
print(f"node1: {node1} node2: {node2}" )
print(f"node3: {node3}" )
tf.print(node1, node2)
tf.print(node3)
|
cs |
-2
v1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import tensorflow as tf
import numpy as np
@tf.function
def adder(a, b):
return a + b
A = tf.constant(1)
B = tf.constant(2)
print(adder(A, B))
C = tf.constant([1,2])
D = tf.constant([3,4])
print(adder(C, D))
E = tf.constant([[1,2,3], [4,5,6]])
F = tf.constant([[2,3,4], [5,6,7]])
print(adder(E, F))
|
cs |

'AI > Deep Learning' 카테고리의 다른 글
[모두를 위한 딥러닝(Sung Kim)|ch.2-1] Linear Regression의 Hypothesis와 cost (0) | 2020.12.29 |
---|---|
[모두를 위한 딥러닝(Sung Kim)|ch.1-1] Machine Learning의 용어와 개념 (2) | 2020.12.19 |