代码之家  ›  专栏  ›  技术社区  ›  Hagbard

Keras:平均pooling1d层和全球平均pooling1d层之间的差异

  •  0
  • Hagbard  · 技术社区  · 7 年前

    谈到角膜的平均聚集层,我有点困惑。 The documentation 声明如下:

    AveragePooling1d:时间数据的平均池。

    争论

    pool_size: Integer, size of the average pooling windows.
    strides: Integer, or None. Factor by which to downscale. E.g. 2 will halve the input. If None, it will default to pool_size.
    padding: One of "valid" or "same" (case-insensitive).
    data_format: A string, one of channels_last (default) or channels_first. The ordering of the dimensions in the inputs.
    

    通道最后对应于具有形状的输入(批处理、步骤, 特征)而通道_首先对应于具有形状的输入 (批次、特征、步骤)。

    输入形状

    If data_format='channels_last': 3D tensor with shape: (batch_size, steps, features)
    If data_format='channels_first': 3D tensor with shape: (batch_size, features, steps)
    

    输出形状

    If data_format='channels_last': 3D tensor with shape: (batch_size, downsampled_steps, features)
    If data_format='channels_first': 3D tensor with shape: (batch_size, features, downsampled_steps)
    

    globalaveragepooling1d:时间数据的全局平均池操作。

    争论

    data_format: A string, one of channels_last (default) or channels_first. The ordering of the dimensions in the inputs.
    

    通道最后对应于具有形状的输入(批处理、步骤, 特征)而通道_首先对应于具有形状的输入 (批次、特征、步骤)。

    输入形状

    if data_format='channels_last':带形状的三维张量:(批量大小、步骤、功能)
    if data_format='channels_first':带形状的三维张量:(批量尺寸、特征、步骤)
    

    输出形状

    带形状的二维张量:(批量大小,特征)

    我(认为我)确实得到了平均池的概念,但我不太明白为什么GlobalAveragePooling1d层只是简单地删除了steps参数。非常感谢你的回答。

    1 回复  |  直到 7 年前
        1
  •  1
  •   xashru    7 年前

    GlobalAveragePooling1D 一样 AveragePooling1D 具有 pool_size=steps . 因此,对于每个特征维度,它需要在所有时间步骤中取平均值。因此,输出具有形状 (batch_size, 1, features) (如果 data_format='channels_last' )他们只是把第二个(或第三个如果 data_format='channels_first' )维数,这就是如何得到输出形状等于 (batch_size, features) .