[英]How to create layer for output for LSTM model?
我仍在学习LSTM分类。
my input dataset is (2386, 3) where (n_rows, n_predictive)
my output dataset is (2386, 7) where (n_rows, n_label)
my input windows size is (2369, 12, 3) where (n_sample, n_input, n_predictive)
my output windows size is (2369, 6, 7) where (n_sample, n_output, n_label)
using this code
model = Sequential()
model.add(LSTM(300, return_sequences=True, input_shape=(n_input, n_predictive)))
model.add(TimeDistributed(Dense(n_label)))
model.add(Activation('softmax'))
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['acc'])
obtain this layer
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
cu_dnnlstm_93 (CuDNNLSTM) (None, 12, 300) 363600
_________________________________________________________________
time_distributed_14 (TimeDis (None, 12, 7) 2107
_________________________________________________________________
activation_13 (Activation) (None, 12, 7) 0
=================================================================
及其错误
Error when checking target: expected activation_13 to have shape (12, 7) but got array with shape (6, 7)
我尝试创建图层,但是无法使用(None,6,7)创建图层,你们对我如何使用(None,6,7)创建图层有任何建议吗?
当我尝试使用相同的输入和输出窗口来拟合模型时,如下所示
input windows size is (2369, 12, 3)
output windows size is (2369, 12, 7)
该模型没有错误,但我发现标签预测比实际延迟了12步。
例如,当我使用其他窗口大小时
input windows size is (2369, 6, 3)
output windows size is (2369, 6, 7)
我发现标签预测比实际延迟了6个步骤。
我已经检查了Windows拆分序列函数,在这里我从此博客https://machinelearningmastery.com/how-to-develop-lstm-models-for-time-series-forecasting/遵循此代码
窗户分开工作正常。 但是似乎LSTM模型工作很奇怪。 LSTM分类模型是否会受到窗口大小的影响?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.