【发布时间】:2020-08-07 20:15:08
【问题描述】:
我正在尝试沿批处理维度重塑 Tensorflow 模型的输入。我想将一些批次样本组合成一个时间序列,以便将其输入 LSTM 层。
具体来说,我有 1024 个样本,我想将它们分成 64 个时间步长的组,结果是 16 批 64 个时间步长,每个时间步长都有原始的 24 个特征。
#input tensor is (1024, 24)
inputLayer = Input(shape=(24,))
#I want it to be (16, 64, 24)
reshapedLayer = layers.Reshape([64, 24])(inputLayer)
lstmLayer = layers.LSTM(128, activation='relu')(reshapedLayer)
这会编译但会引发运行时错误
tensorflow.python.framework.errors_impl.InvalidArgumentError:
Input to reshape is a tensor with 24576 values, but the requested shape has 1572864
我明白错误告诉我什么,但我不确定修复它的正确方法。
【问题讨论】:
标签: python tensorflow lstm reshape tensor