Vision functions
torch.nn.functional.pixel_shuffle(input, upscale_factor)[source]
将形状为[, Cr^2, H, W]的Tensor重新排列成形状为[C, Hr, Wr]的Tensor.
详细请看PixelShuffle.
形参说明:
- input (Variable) – 输入
- upscale_factor (int) – 增加空间分辨率的因子.
例子:
ps = nn.PixelShuffle(3)input = autograd.Variable(torch.Tensor(1, 9, 4, 4))output = ps(input)print(output.size())torch.Size([1, 1, 12, 12])
torch.nn.functional.pad(input, pad, mode='constant', value=0)[source]
填充Tensor.
目前为止,只支持2D和3D填充. Currently only 2D and 3D padding supported. 当输入为4D Tensor的时候,pad应该是一个4元素的tuple (pad_l, pad_r, pad_t, pad_b ) ,当输入为5D Tensor的时候,pad应该是一个6元素的tuple (pleft, pright, ptop, pbottom, pfront, pback).
形参说明:
- input (Variable) – 4D 或 5D tensor
- pad (tuple) – 4元素 或 6-元素 tuple
- mode – ‘constant’, ‘reflect’ or ‘replicate’
- value – 用于constant padding 的值.