CircularPad1d¶
- class torch.nn.CircularPad1d(padding)[source][source]¶
使用輸入邊界的循環填充來填充輸入 tensor。
維度開始處的 Tensor 值用於填充結尾,而結尾處的值用於填充開頭。 如果應用負填充,則會移除 tensor 的結尾。
對於 N 維填充,請使用
torch.nn.functional.pad()
。- 形狀 (Shape)
輸入: 或 。
輸出: 或 ,其中
範例
>>> 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.]]])