Skip to content

Instantly share code, notes, and snippets.

@xunge
Last active July 3, 2019 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xunge/5d300183dae396e8f987e27ac2a28c3d to your computer and use it in GitHub Desktop.
Save xunge/5d300183dae396e8f987e27ac2a28c3d to your computer and use it in GitHub Desktop.
线性回归的训练过程
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(1000):
for j in range(4):
sess.run(train, feed_dict={x: np.expand_dims(X[j], 0), y: np.expand_dims(Y[j], 0)})
loss_ = sess.run(loss, feed_dict={x: X, y: Y})
print("step: %d, loss: %.3f" % (i, loss_))
print("X: %r" % X)
print("pred: %r" % sess.run(out, feed_dict={x: X}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment