Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bias = params.get('bias', None)
return F.batch_norm(
input, self.running_mean, self.running_var, weight, bias,
self.training or not self.track_running_stats,
exponential_average_factor, self.eps)
class MetaBatchNorm1d(_MetaBatchNorm):
__doc__ = nn.BatchNorm1d.__doc__
def _check_input_dim(self, input):
if input.dim() != 2 and input.dim() != 3:
raise ValueError('expected 2D or 3D input (got {}D input)'
.format(input.dim()))
class MetaBatchNorm2d(_MetaBatchNorm):
__doc__ = nn.BatchNorm2d.__doc__
def _check_input_dim(self, input):
if input.dim() != 4:
raise ValueError('expected 4D input (got {}D input)'
.format(input.dim()))
class MetaBatchNorm3d(_MetaBatchNorm):
__doc__ = nn.BatchNorm3d.__doc__
def _check_input_dim(self, input):
if input.dim() != 5:
raise ValueError('expected 5D input (got {}D input)'
.format(input.dim()))
if self.num_batches_tracked is not None:
self.num_batches_tracked += 1
if self.momentum is None: # use cumulative moving average
exponential_average_factor = 1.0 / float(self.num_batches_tracked)
else: # use exponential moving average
exponential_average_factor = self.momentum
weight = params.get('weight', None)
bias = params.get('bias', None)
return F.batch_norm(
input, self.running_mean, self.running_var, weight, bias,
self.training or not self.track_running_stats,
exponential_average_factor, self.eps)
class MetaBatchNorm1d(_MetaBatchNorm):
__doc__ = nn.BatchNorm1d.__doc__
def _check_input_dim(self, input):
if input.dim() != 2 and input.dim() != 3:
raise ValueError('expected 2D or 3D input (got {}D input)'
.format(input.dim()))
class MetaBatchNorm2d(_MetaBatchNorm):
__doc__ = nn.BatchNorm2d.__doc__
def _check_input_dim(self, input):
if input.dim() != 4:
raise ValueError('expected 4D input (got {}D input)'
.format(input.dim()))
class MetaBatchNorm3d(_MetaBatchNorm):
__doc__ = nn.BatchNorm1d.__doc__
def _check_input_dim(self, input):
if input.dim() != 2 and input.dim() != 3:
raise ValueError('expected 2D or 3D input (got {}D input)'
.format(input.dim()))
class MetaBatchNorm2d(_MetaBatchNorm):
__doc__ = nn.BatchNorm2d.__doc__
def _check_input_dim(self, input):
if input.dim() != 4:
raise ValueError('expected 4D input (got {}D input)'
.format(input.dim()))
class MetaBatchNorm3d(_MetaBatchNorm):
__doc__ = nn.BatchNorm3d.__doc__
def _check_input_dim(self, input):
if input.dim() != 5:
raise ValueError('expected 5D input (got {}D input)'
.format(input.dim()))