ReplicationPad1d¶
- class torch.nn.ReplicationPad1d(padding)[源代码]¶
使用输入边界的复制来填充输入张量。
对于N维填充,使用
torch.nn.functional.pad()。- Shape:
输入: 或 。
输出: 或 , 其中
示例:
>>> m = nn.ReplicationPad1d(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([[[0., 0., 0., 1., 2., 3., 3., 3.], [4., 4., 4., 5., 6., 7., 7., 7.]]]) >>> # 对不同边使用不同的填充 >>> m = nn.ReplicationPad1d((3, 1)) >>> m(input) tensor([[[0., 0., 0., 0., 1., 2., 3., 3.], [4., 4., 4., 4., 5., 6., 7., 7.]]])