Unverified Commit b17d49f8 authored by Yih-Dar's avatar Yih-Dar Committed by GitHub
Browse files

Fix `_upsample_2d` (#535)



* Fix _upsample_2d
Co-authored-by: default avatarydshieh <ydshieh@users.noreply.github.com>
parent b8d1f2d3
......@@ -149,7 +149,6 @@ class FirUpsample2D(nn.Module):
stride = (factor, factor)
# Determine data dimensions.
stride = [1, 1, factor, factor]
output_shape = ((x.shape[2] - 1) * factor + convH, (x.shape[3] - 1) * factor + convW)
output_padding = (
output_shape[0] - (x.shape[2] - 1) * stride[0] - convH,
......@@ -161,7 +160,7 @@ class FirUpsample2D(nn.Module):
# Transpose weights.
weight = torch.reshape(weight, (num_groups, -1, inC, convH, convW))
weight = weight[..., ::-1, ::-1].permute(0, 2, 1, 3, 4)
weight = torch.flip(weight, dims=[3, 4]).permute(0, 2, 1, 3, 4)
weight = torch.reshape(weight, (num_groups * inC, -1, convH, convW))
x = F.conv_transpose2d(x, weight, stride=stride, output_padding=output_padding, padding=0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment