我试图从我的LSTM
模型中预测一个结果
我的模型具有n_features = 32
和time_step = 100
,并带有以下代码
model = tf.keras.Sequential([
tf.keras.layers.InputLayer( input_shape=(time_step , n_features)),
tf.keras.layers.LSTM(64),
tf.keras.layers.Dense(1)]
)
我使用生成器训练了模型
generator = TimeseriesGenerator(x_feature,y_target,length=time_step ,batch_size = 128)
[当我尝试使用形状为(2,32)
的测试数据集来预测模型时,该数据集具有2行和32个特征。
(我打算从我的模型中获得2个预测)
我有以下错误
ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=3, found ndim=2.
Full shape received: [None, 32]
我理解这一点是因为我的测试数据集的形状为[None,32]
,但如何重塑形状,使其变为(100,32)
的形状
我尝试使用]重塑形状>
x_feature.reshape(-1,100,36) model.predict(x_feature)
但是显示
ValueError: cannot reshape array of size 64 into shape (100,36)
当我的模型输入形状为
100,36
但测试数据集的形状为2,36
时,如何解决此类重塑问题?
谢谢!
[我试图从我的LSTM模型中预测单个结果,我的模型的n_features = 32且time_step = 100,以下代码模型= tf.keras.Sequential([tf.keras.layers.InputLayer(...
Keras
模型在inputs
层的情况下始终希望(batch_size, time_steps, n_features)
具有形状LSTM
。训练时它之所以有效,是因为您训练了多个示例,即以固定的批次大小进行训练。但是,当您进行预测并使用one