2019-02-17
阅读量:
635
Tensorflow如何可视化展示线性回归
# Calculating the predictions
predictions = weight * x + bias
print("Training cost =", training_cost, "Weight =", weight, "bias =", bias, '\n')
输出:
Training cost = 5.3110332 Weight = 1.0199214 bias = 0.02561663
请注意,在这种情况下,权重和偏差都是标量。这是因为我们在训练数据中只考虑了一个因变量。如果我们的训练数据集中有m个因变量,则权重将是m维向量,而偏差将是标量。
最后,我们将绘制我们的结果。
# Plotting the Results
plt.plot(x, y, 'ro', label ='Original data')
plt.plot(x, predictions, label ='Fitted line')
plt.title('Linear Regression Result')
plt.legend()
plt.show()







评论(0)


暂无数据
推荐帖子
0条评论
0条评论
1条评论