簡體   English   中英

Keras:AveragePooling1D 層和 GlobalAveragePooling1D 層的區別

[英]Keras: Difference between AveragePooling1D layer and GlobalAveragePooling1D layer

當談到 Keras 的平均池化層時,我有點困惑。 文檔說明如下:

AveragePooling1D:時態數據的平均池化。

參數

pool_size: Integer, size of the average pooling windows. strides: Integer, or None. Factor by which to downscale. Eg 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.

channel_last 對應於具有形狀(批次、步驟、特征)的輸入,而 channels_first 對應於具有形狀(批次、特征、步驟)的輸入。

輸入形狀

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.

channel_last 對應於具有形狀(批次、步驟、特征)的輸入,而 channels_first 對應於具有形狀(批次、特征、步驟)的輸入。

輸入形狀

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)

輸出形狀

具有形狀的 2D 張量:(batch_size, features)

我(認為我)確實得到了平均池化的概念,但我真的不明白為什么 GlobalAveragePooling1D 層只是刪除了步驟參數。 非常感謝您的回答。

GlobalAveragePooling1D與帶pool_size=steps AveragePooling1D相同。 因此,對於每個特征維度,它在所有時間步長中取平均值。 因此輸出具有形狀(batch_size, 1, features) (如果data_format='channels_last' )。 他們只是壓平第二個(或第三個,如果data_format='channels_first' )維度,這就是你如何獲得等於(batch_size, features)輸出形狀。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM