MaxPool1d¶
- class torch.nn.MaxPool1d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)[原始碼][原始碼]¶
在一個由多個輸入平面組成的輸入訊號上應用一維最大池化。
在最簡單的情況下,輸入大小為 且輸出大小為 的層的輸出值可以精確地描述為:
如果
padding非零,則輸入在兩側隱式填充padding個點,填充值為負無窮。dilation是滑動視窗內元素之間的步長。這個 連結 對池化引數有很好的視覺化說明。注意
當 ceil_mode=True 時,如果滑動視窗從左側填充區域或輸入內部開始,則允許越界。從右側填充區域開始的滑動視窗將被忽略。
- 引數
stride (Union[int, tuple[int]]) – 滑動視窗的步長,必須 > 0。預設值為
kernel_size。padding (Union[int, tuple[int]]) – 在兩側新增的隱式負無窮填充,必須 >= 0 且 <= kernel_size / 2。
return_indices (bool) – 如果為
True,將返回最大值以及對應的索引 (argmax)。這對於後續使用torch.nn.MaxUnpool1d非常有用。ceil_mode (bool) – 如果為
True,將使用 ceil 而非 floor 計算輸出形狀。這確保了輸入張量中的每個元素都被滑動視窗覆蓋。
- 形狀
輸入: 或 。
輸出: 或 ,其中
示例
>>> # pool of size=3, stride=2 >>> m = nn.MaxPool1d(3, stride=2) >>> input = torch.randn(20, 16, 50) >>> output = m(input)