# 데이터 준비
x = 3.0
y = 10.0

tf.reset_default_graph()
# 모델만들기
X = tf.placeholder(tf.float32, shape=())
Y = tf.placeholder(tf.float32, shape=())

W = tf.Variable(tf.random_normal(shape=()))
B = tf.Variable(tf.random_normal(shape=()))
H = tf.add(tf.multiply(x, W), B)

loss = tf.square(tf.subtract(y, H))
optimizer = tf.train.GradientDescentOptimizer(0.01).minimize(loss)

# 학습
sess = tf.Session()
sess.run(tf.global_variables_initializer())

for i in range(20):
  sess.run(optimizer, feed_dict = {X:x, Y:y})
  print(sess.run([loss, W, B], feed_dict={X:x, Y:y}))

'Develop > AI' 카테고리의 다른 글

Scikit-learn LinearRegression  (0) 2019.07.15
MNIST  (0) 2019.07.14

+ Recent posts