hojeomi blog
1. TensorFlow와 간단한 Linear Regression 본문
In [25]:
from IPython.core.display import display, HTML
display(HTML("<style> .container{width:90% !important;}</style>"))
import tensorflow as tf
import os
# info 로그를 필터링 하려면 1, warning 로그는 2, error 로그는 3
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
In [26]:
hellow = tf.constant("hellow!")
print(hellow)
In [ ]:
In [27]:
# 앞쪽 레이어
In [28]:
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0, tf.float32)
print(node1, node2)
In [29]:
node3 = node1 + node2
print(node3)
In [ ]:
In [30]:
# 뒷쪽 레이어의 노드를 함수로 정의
In [31]:
@tf.function
def forward():
return node1 + node2
In [32]:
out_a = forward()
In [33]:
print(out_a)
In [34]:
if out_a == node3:
print("오잉")
In [ ]:
(구버전)placeholder -> @tf.function 사용하기¶
In [35]:
@tf.function
def Add(a, b):
return a + b
In [36]:
a = tf.constant(1)
b = tf.constant(2)
c = Add(a, b)
print(c)
In [37]:
c = tf.constant([1,2])
d = tf.constant([3,4])
e = Add(c,d)
print(e)
In [38]:
f = Add(c,a)
In [39]:
f
Out[39]:
In [ ]:
In [ ]:
'AI > Machine & Deep Learning' 카테고리의 다른 글
4-1. multi-variable linear regression (0) | 2021.01.15 |
---|---|
4-2. multi-variable linear regression을 TensorFlow에서 구현하기 (0) | 2021.01.15 |
3-2. Linear Regression 의 cost 최소화에서 Gradient 조절 (0) | 2021.01.14 |
3-1. Linear Regression 의 cost 최소화의 TensorFlow 구현 (0) | 2021.01.14 |
2. Linear Regression의 cost 최소화 알고리즘의 원리 설명 (0) | 2021.01.13 |
Comments