Created
April 25, 2020 06:39
-
-
Save sicongzhao/2e7bb2fa9591a754cd34818d72f0d1ac to your computer and use it in GitHub Desktop.
Demystify Transposed Convolutional Layer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a TCL layer with stride=2, output_padding=1 | |
transConv4 = nn.ConvTranspose2d(1, 1, 3, stride=2, output_padding=1, bias=False) | |
# Set kernel weights to be 1 | |
transConv4.weight.data = torch.ones(1,1,3,3) | |
# Calculate | |
transConv4(input_data) | |
# Output: | |
# tensor([[[[ 1., 1., 3., 2., 2., 0.], | |
# [ 1., 1., 3., 2., 2., 0.], | |
# [ 4., 4., 10., 6., 6., 0.], | |
# [ 3., 3., 7., 4., 4., 0.], | |
# [ 3., 3., 7., 4., 4., 0.], | |
# [ 0., 0., 0., 0., 0., 0.]]]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment