f(x) = ax + b
import tensorflow as tf
import pandas as pd
data = pd.read_csv(r’…xxx.csv’)
x = data.Education
y = data.Income
model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(1, input_shape=([1,])))
model.summary()
model.compile(optimizer = ‘adam’, loss=‘mse’)
history = model.fit(x, y, epochs=100)
model.predict(x) # 对x的预测
model.predict(pd.Series([20])
本文介绍如何使用TensorFlow构建线性回归模型,通过读取csv文件中的教育水平和收入数据,训练模型并进行预测。模型采用单层全连接神经网络,使用Adam优化器最小化均方误差。
1102

被折叠的 条评论
为什么被折叠?



