首页 > 解决方案 > 如何为 LSTM 填充时间戳

问题描述

我正在尝试为 LSTM 填充我的序列数据,我的数据 x 看起来像

x = [[[1],[2],[3]],[[1],[2]],...]

在模型中,我尝试像这样填充:

from tensorflow.keras.preprocessing.sequence import pad_sequences

x = Input(batch_shape = (None, None, 1), dtype = 'int32', name = 'x')
padded_x = pad_sequences(x, padding="post")

然后,我收到一条错误消息:

len is not well defined for symbolic Tensors. (x:0) Please call `x.shape` rather than `len(x)` for shape information.

我的猜测是它发生batch_shape = (None, None, 1)在输入层中。但我需要使用它,因为每个样本都有不同的时间戳。

标签: pythontensorflowkeraslstm

解决方案


推荐阅读