Skip to content

Instantly share code, notes, and snippets.

@lasseha
Last active August 23, 2019 14:15
Show Gist options
  • Select an option

  • Save lasseha/be03f33a75ddbb44dfb10c063364b6fe to your computer and use it in GitHub Desktop.

Select an option

Save lasseha/be03f33a75ddbb44dfb10c063364b6fe to your computer and use it in GitHub Desktop.
conv upsampling
class ConvUpsampling(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0):
super(ConvUpsampling, self).__init__()
self.scale_factor = kernel_size
self.conv = nn.Sequential(
nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding, bias=False),
nn.BatchNorm2d(out_channels),
nn.LeakyReLU()
)
def forward(self, x):
x = F.interpolate(x, scale_factor=self.scale_factor, mode='bilinear')
return self.conv(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment