如何使用TensorFlow库理解线性回归学习算法示例?

时间:2019-03-07 03:51:27

标签: tensorflow

我试图理解linear_regression.py示例(https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/linear_regression.py)。我是Tensorflow和Python的新手。

有人可以解释“ 拟合所有训练数据”和“ 每个时期显示日志”下写的代码吗?

# Fit all training data
for epoch in range(training_epochs):
    for (x, y) in zip(train_X, train_Y): #Creates a Dataset by zipping together the given datasets.
        sess.run(optimizer, feed_dict={X: x, Y: y})

    # Display logs per epoch step
    if (epoch+1) % display_step == 0:
        c = sess.run(cost, feed_dict={X: train_X, Y:train_Y})
        print("Epoch:", '%04d' % (epoch+1), "cost=", "{:.9f}".format(c), \
            "W=", sess.run(W), "b=", sess.run(b))

0 个答案:

没有答案