鱼C论坛

 找回密码
 立即注册
查看: 1231|回复: 0

求tensorflow大神来解惑一下

[复制链接]
发表于 2022-2-20 12:37:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
import numpy as np
import matplotlib.pyplot as plt
data = pd.read_csv('C:\\Users\wangying\Desktop\\advertising.csv')
# plt.scatter(data.newspaper,data.sales)
x=data.iloc[:,1:-1]
y=data.iloc[:,-1]
model=tf.keras.Sequential([tf.keras.layers.Dense(10,input_shape=(3,),activation='relu'),tf.keras.layers.Dense(1)])
model.summary()
model.compile(optimizer='adam',loss='mse')
model.fit(x,y,epochs=10000)


这是代码

ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 3 but received input with shape [None, 2]

这是错误


TV        radio        newspaper        sales
230.1        37.8        69.2        22.1
44.5        39.3        45.1        10.4
17.2        45.9        69.3        9.3
151.5        41.3        58.5        18.5
180.8        10.8        58.4        12.9
这是我的数据

各位大佬,我知道问题出在哪里,但是我输入的就是三个数据,难道input_shape不应该是3么,但是怎么提示我接收的只能是2维呢

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-6 08:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表