Skip to content

Instantly share code, notes, and snippets.

@sicongzhao
Last active April 25, 2020 06:08
Show Gist options
  • Save sicongzhao/4beccdc2178c643c1f827b6cac8b8908 to your computer and use it in GitHub Desktop.
Save sicongzhao/4beccdc2178c643c1f827b6cac8b8908 to your computer and use it in GitHub Desktop.
Demystify Transposed Convolutional Layer
# Create a TCL layer with stride=2, padding=1
transConv3 = nn.ConvTranspose2d(1, 1, 3, stride=2, padding=1, bias=False)
# Set kernel weights to be 1
transConv3.weight.data = torch.ones(1,1,3,3)
# Calculate
transConv3(input_data)
# Output:
# tensor([[[[ 1., 3., 2.],
# [ 4., 10., 6.],
# [ 3., 7., 4.]]]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment