LSTM预测中形状错误

我已经训练了一个模型:

trainX = trainX.reshape(1, 43164, 17)trainY = trainY.reshape(43164, 1)model = Sequential()model.add(LSTM(2, input_shape=(43164, 17)))model.add(Dense(1))model.compile(loss='mean_squared_error', optimizer='adam')model.fit(trainX, trainY[0], epochs=100)testX.shape # (8633, 17)testX = testX.reshape(1, 8633, 17)

当我对这些数据进行预测时,我得到了一个错误:

Error when checking input: expected lstm_26_input to have shape (43164, 17) but got array with shape (8633, 17)

我应该做些什么才能获得好的结果?


回答:

在深度学习网络的序列模型中,您可以使用有限的短窗口和改变窗口的步长来传递数据,或者

传递一个由一维向量组成的完整序列

trainX = trainX.reshape( 43164,1, 17)trainY = trainY.reshape(43164, 1)model = Sequential()model.add(LSTM(2, input_shape=(1, 17)))model.add(Dense(1))model.compile(loss='mean_squared_error', optimizer='adam')model.fit(trainX, trainY[0], epochs=100)testX.shape # (8633, 17)testX = testX.reshape(8633,1, 17)

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注