import tensorflow as tf
xData = [1 ,2 ,3 ,4 ,5 ,6 ,7]
yData = [25000, 55000, 75000, 110000, 128000, 155000, 180000]
W = tf.Variable(tf.random_uniform([1], -100, 100))
b = tf.Variable(tf.random_uniform([1], -100, 100))
X = tf.placeholder(tf.float32)
Y = tf.placeholder(tf.float32)
H = W *X + b
cost = tf.reduce_mean(tf.square(H-Y))
a=tf.Variable(0.01)
optimizer = tf.train.GradientDescentOptimizer(a)
train = optimizer.minimize(cost)
init = tf.global_variables_initalizer()
sess = tf.Session()
sess.run(init)
for i in ragne(10000):
sess.run(train, feed_dict={X : xData, Y : yData})
if i % 500 == 0 :
print(i, sess.run(cost, feed_dict={X : xData, Y: yData}), sess.run(W), sess.run(b))
print (sess.run(H, feed_dict={X : [8]}))
'기타 > Tenserflow' 카테고리의 다른 글
[Tensorflow]설치 및 개발환경구성 (0) | 2018.12.19 |
---|