Compute the instance normalization within only the background region, in which the mean and standard variance are measured from the features in background region.
(self, dims_in, eps=1e-5)
| 4 | |
| 5 | class RAIN(nn.Module): |
| 6 | def __init__(self, dims_in, eps=1e-5): |
| 7 | '''Compute the instance normalization within only the background region, in which |
| 8 | the mean and standard variance are measured from the features in background region. |
| 9 | ''' |
| 10 | super(RAIN, self).__init__() |
| 11 | self.foreground_gamma = nn.Parameter(torch.zeros(dims_in), requires_grad=True) |
| 12 | self.foreground_beta = nn.Parameter(torch.zeros(dims_in), requires_grad=True) |
| 13 | self.background_gamma = nn.Parameter(torch.zeros(dims_in), requires_grad=True) |
| 14 | self.background_beta = nn.Parameter(torch.zeros(dims_in), requires_grad=True) |
| 15 | self.eps = eps |
| 16 | |
| 17 | def forward(self, x, mask): |
| 18 | mask = F.interpolate(mask.detach(), size=x.size()[2:], mode='nearest') |
nothing calls this directly
no outgoing calls
no test coverage detected