PyTorch Upsample() 函数实现上采样
import torch
import torch.nn as nn
input = torch.arange(1, 5, dtype=torch.float32).view(1,1,2,2)
print(input)
m = nn.Upsample(scale_factor=2, mode='bicubic', align_corners=True)
m(input)
输出结果如下:
tensor([[[[1., 2.],
[3., 4.]]]])
tensor([[[[1.0000, 1.3148, 1.6852, 2.0000],
[1.6296, 1.9444, 2.3148, 2.6296],
[2.3704, 2.6852, 3.0556, 3.3704],
[3.0000, 3.3148, 3.6852, 4.0000]]]])
Ref: