哈哈哈ha1 发表于 2022-2-20 12:37:35

求tensorflow大神来解惑一下

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()
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

这是错误


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维呢

页: [1]
查看完整版本: 求tensorflow大神来解惑一下