반응형
import tensorflow as tf
x_data = [1, 2, 3, 4, 5]
y_data = [1, 2, 3, 4, 5]
W = tf.Variable(3.5)
b = tf.Variable(1.0)
# hypothesis = W * x + b
hypo = W * x_data + b
H(x) = 가설함수
hypotthesis라고 하며 파이썬(tensorflow)에서 구현할수 있도록 변경
# cost = (hypo - y_data) ** 2
cost = tf.reduce_mean(tf.square(hypo - y_data))
코스트함수.
가설에 의한 출력 - 실제출력 한 값의 제곱값들의 평균
- tf.reduce_mean()
v = [1., 2., 3., 4.] tf.reduce_mean(v) # 2.5
차원이 하나 줄어듬.
- tf.square() = 제곱
반응형
'Python > Python_tensorflow | 텐서플로우' 카테고리의 다른 글
Cost(비용) 최소의 구체적인 방법 - 텐서플로우(tensorflow) (0) | 2020.05.21 |
---|---|
Parameter(W,b) Update - 텐서플로우(tensorflow) (0) | 2020.05.21 |
Gradient descent(경사하강법, 경사하강알고리즘) - 텐서플로우(tensorflow) (0) | 2020.05.20 |
Regression(회귀) - 텐서플로우(tensorflow) (0) | 2020.05.19 |
머신러닝 용어 및 개념 - 텐서플로우(tensorflow) (0) | 2020.05.18 |
댓글