ReflectionPad1d#
- class torch.nn.modules.padding.ReflectionPad1d(padding)[source]#
使用輸入邊界的反射來填充輸入張量。
對於 N 維填充,請使用
torch.nn.functional.pad()。- 形狀
輸入: 或 。
輸出: 或 , 其中
示例
>>> m = nn.ReflectionPad1d(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., 1., 0., 1., 2., 3., 2., 1.], [6., 5., 4., 5., 6., 7., 6., 5.]]]) >>> # using different paddings for different sides >>> m = nn.ReflectionPad1d((3, 1)) >>> m(input) tensor([[[3., 2., 1., 0., 1., 2., 3., 2.], [7., 6., 5., 4., 5., 6., 7., 6.]]])