CircularPad1d#
- class torch.nn.modules.padding.CircularPad1d(padding)[源]#
使用輸入邊界的迴圈填充來填充輸入張量。
張量維度開頭的值用於填充結尾,維度結尾的值用於填充開頭。如果應用負填充,則會移除張量的末端。
對於 N 維填充,請使用
torch.nn.functional.pad()。- 形狀
輸入: 或 。
輸出: 或 ,其中
示例
>>> m = nn.CircularPad1d(2) >>> input = torch.arange(8, dtype=torch.float).reshape(1, 2, 4) >>> input tensor([[[0., 1., 2., 3.], [4., 5., 6., 7.]]]) >>> m(input) tensor([[[2., 3., 0., 1., 2., 3., 0., 1.], [6., 7., 4., 5., 6., 7., 4., 5.]]]) >>> # using different paddings for different sides >>> m = nn.CircularPad1d((3, 1)) >>> m(input) tensor([[[1., 2., 3., 0., 1., 2., 3., 0.], [5., 6., 7., 4., 5., 6., 7., 4.]]])