简体   繁体   English

MLP model 我做错了什么?

[英]What am I doing wrong with the MLP model?

I am developing a time series forecast model using python MLP model.我正在使用 python MLP model 开发时间序列预测 model。 My training sample has 550 events with 9 variables.我的训练样本有 550 个事件和 9 个变量。 I have a separate file for testing.我有一个单独的文件用于测试。 I want to forecast at t+1 just one of the 9 variable.我想在 t+1 预测 9 个变量之一。 Since it is a time series I did 547 portions of 3 events walking one time each timefor X (547, 3, 9).由于它是一个时间序列,我为 X (547, 3, 9) 做了 3 个事件的 547 个部分,每次步行一次。 And y (547,) is one variable at t+1.并且 y (547,) 是 t+1 时的一个变量。

model1 = Sequential()
model1.add(Dense(1, activation='tanh', input_shape=(3, 9)))
model1.add(Dense(1, activation='linear'))
model1.summary()

model1.compile(loss='mse', optimizer='adam', metrics=['mae'])

model1.fit(X, y, epochs=2000, verbose=1)

ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 547 arrays:预计会看到 1 个数组,但得到了以下 547 arrays 列表:

[array([[3.00000000e+01, 1.10000000e+01, 2.01500000e+03, 1.40000000e+01,
        8.36778275e-01, 2.07423694e-01, 7.65763170e-01, 5.07591141e-01,
        9.61668222e-01],
       [3.00000000e+01, 1.1000...

For a model with a single input you need to give a single array where the first dimension are the samples.对于具有单个输入的 model,您需要提供一个数组,其中第一个维度是样本。 You are giving a list.你给了一个清单。 Convert to array (eg using np.stack(X)).转换为数组(例如使用 np.stack(X))。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM