import matplotlib.pyplot as plt
%matplotlib inline
plt.scatter(data_x, data_y)
<matplotlib.collections.PathCollection at 0x10dbfe908>
import tensorflow as tf
/anaconda3/envs/py35/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.6 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
return f(*args, **kwds)
/anaconda3/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
w = tf.Variable(1., name='quanzhong')
b = tf.Variable(0., name='pianzhi')
x = tf.placeholder(tf.float32, shape=None)
y = tf.placeholder(tf.float32, shape=[None])
pred = tf.multiply(x, w) + b
loss = tf.reduce_sum(tf.squared_difference(pred, y))
for i in range(10000):
sess.run(train_step, feed_dict={x:data_x, y:data_y})
if i%1000 == 0:
print(sess.run([loss, w ,b], feed_dict={x:data_x, y:data_y}))