Spaces:
Sleeping
Sleeping
File size: 716 Bytes
6146368 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
from torch import nn
class UpsamplingLayer(nn.Module):
def __init__(self, in_channels, out_channels):
super(UpsamplingLayer, self).__init__()
self.layer = nn.Sequential(
nn.UpsamplingBilinear2d(scale_factor=2),
nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1),
nn.GELU()
)
self.reset_parameters()
def forward(self, x):
return self.layer(x)
def reset_parameters(self):
for module in self.modules():
if isinstance(module, nn.Conv2d):
nn.init.xavier_uniform_(module.weight)
if module.bias is not None:
nn.init.constant_(module.bias, 0)
|