nn.ConvTranspose2d 怎么理解怎么用

关于具体内容:
解释超级好!可视化

如果只是想拿来当作一个工具的话 根本不要考虑那么多,
如果保持
nn.conv2d跟nn.convTranspose2d中的参数一致,那么就是input 跟output互相转换,如下:

input1 = torch.randn(4,3,4,4)
input2 = torch.randn(4,3,2,2)

print("-------------------------down---------------------------")
m1 = nn.Conv2d(3,8,3,stride=1,padding=0,padding_mode="reflect")


ouput1 = m1(input1)
print(input1.shape)
print(ouput1.shape)

print("--------------------------up----------------------------")
n1 = nn.ConvTranspose2d(3,8,3,stride=1,padding=0)
ouput2 = n1(input2)
print(input2.shape)
print(ouput2.shape)

输出

-------------------------down---------------------------
torch.Size([4, 3, 4, 4])
torch.Size([4, 8, 2, 2])
--------------------------up----------------------------
torch.Size([4, 3, 2, 2])
torch.Size([4, 8, 4, 4])

Process finished with exit code 0

你可能感兴趣的:(python,pytorch,python,人工智能)