圆形填充 1d ¶
- 类 torch.nn.CircularPad1d(padding)[source][source] ¶
使用输入边界的圆形填充对输入张量进行填充。
维度开头的张量值用于填充末尾,末尾的值用于填充开头。如果应用负填充,则张量的两端将被移除。
对于 N 维填充,使用
torch.nn.functional.pad()
。- 参数:
填充(int,tuple)- 填充的大小。如果为 int,则在所有边界使用相同的填充。如果为 2-tuple,则使用( , )。
- 形状:
输入: 或 。
输出: 或 ,其中
示例:
>>> 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.]]])