人工智能|TensorFlow机器学习小案例(三)

利用TensorFlow实现线性回归模型demo

import numpy as np import tensorflow as tf import matplotlib.pyplot as plt# 随机生成1000个点,围绕在y=0.1x+0.3的直线周围 num_points = 1000 vectors_set = [] for i in range(num_points): x1 = np.random.normal(0.0,0.55) y1 = x1 * 0.1 + 0.3 + np.random.normal(0.0,0.03) vectors_set.append([x1, y1])# 生成一些样本 x_data = https://www.it610.com/article/[v[0] for v in vectors_set] y_data = [v[1] for v in vectors_set]plt.scatter(x_data, y_data, c='r', label='Original data') #plt.plot(x_data, y_data, c='r', label='Original data') 画线 plt.legend() plt.show()

【人工智能|TensorFlow机器学习小案例(三)】人工智能|TensorFlow机器学习小案例(三)
文章图片

    推荐阅读