【发布时间】:2020-08-03 15:32:42
【问题描述】:
我正在尝试使用 Keras 对单变量时间序列进行预测。
NN 模型看起来像
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv1d (Conv1D) (None, None, 25) 150
_________________________________________________________________
lstm (LSTM) (None, None, 1024) 4300800
_________________________________________________________________
dropout (Dropout) (None, None, 1024) 0
_________________________________________________________________
lstm_1 (LSTM) (None, None, 1024) 8392704
_________________________________________________________________
dropout_1 (Dropout) (None, None, 1024) 0
_________________________________________________________________
lstm_2 (LSTM) (None, None, 1024) 8392704
_________________________________________________________________
dropout_2 (Dropout) (None, None, 1024) 0
_________________________________________________________________
lstm_3 (LSTM) (None, None, 1024) 8392704
_________________________________________________________________
dropout_3 (Dropout) (None, None, 1024) 0
_________________________________________________________________
dense (Dense) (None, None, 1) 1025
=================================================================
Total params: 29,480,087
Trainable params: 29,480,087
Non-trainable params: 0
_________________________________________________________________
我的数据使用该系列的前 3 个值进行窗口化,以预测下一个。 因此我的测试数据集看起来像
list(dataset.as_numpy_iterator())
[array([[[ 0. ],
[ 0.02346429],
[ 0.04559132]],
[[ 0. ],
[ 0.02161974],
[ 0.13014923]],
[[ 0. ],
[ 0.10623277],
[-0.02918068]],
[[ 0. ],
[-0.12240955],
[-0.21869095]]])]
一切都很好,但是当我将它提供给 model.predict(dataset) 时,它吐出的输出是
array([[[ 0.01316399],
[ 0.03728709],
[ 0.06164959]],
[[ 0.01316399],
[ 0.03512047],
[ 0.1292857 ]],
[[ 0.01316399],
[ 0.1172413 ],
[-0.01671433]],
[[ 0.01316399],
[-0.10654409],
[-0.16395506]]], dtype=float32)
这个例子的形状是(4, 3, 1)
考虑到我的 NN 的最后一层是具有单个单元的 Dense,我希望只为每个三元组输入特征获得一个预测。为什么每个训练示例的预测中似乎都有三个输出?
【问题讨论】:
标签: python tensorflow machine-learning keras lstm