【问题标题】:What is the difference between batch_size from fit() method and batch from LSTM inputs ? Pythonfit() 方法中的 batch_size 和 LSTM 输入中的批处理有什么区别? Python
【发布时间】:2021-11-21 12:32:41
【问题描述】:

我无法理解fit() 方法的 batch_size 与来自 LSTM 输入维度的批次之间的区别:形状为 [批次、时间步长、特征] 的 3D 张量。 (请参阅输入 keras:https://keras.io/api/layers/recurrent_layers/lstm/)。

为此我还可以添加epochs。

如果我有一个包含 1000 个值的数据集,其格式已针对 LSTM 进行了重构,并且我的时间步长为 50(即 50 个 LSTM 单元),那么数据将如何表现?我想不通。

【问题讨论】:

    标签: python tensorflow keras lstm


    【解决方案1】:

    *layer* 的输入维度将为 (batch_size, ...),因为无论您有多少样本,model.fit() 都会将您的输入分成 (batch_size, ...) 的块。这是沿第一个维度完成的,因此时间步长维度不会改变任何内容。

    您输入的形状...

    (1000, 50, 25) # let's say you have 25 features
    

    ...会像这样进入LSTM层:

    (16, 50, 25) # let's say you have batch_size of 16
    (16, 50, 25)
    (16, 50, 25)
    (16, 50, 25)
    (16, 50, 25)
    ...
    (1000 % 16, 50, 25)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-05
      • 1970-01-01
      • 2018-06-26
      相关资源
      最近更新 更多