Affine

class dragon.vm.torch.nn.Affine(
  num_features,
  bias=True,
  fix_weight=False,
  fix_bias=False,
  inplace=False
)[source]

Apply affine transformation.

Affine is often taken as a post-processing of normalization.

Examples:

m = torch.nn.Affine(5)

# Apply a 2d transformation
x2d = torch.ones(3, 5)
y2d = m(x2d)

# Apply a 3d transformation
x3d = torch.ones(3, 5, 4)
y3d = m(x3d)

# Apply a 4d transformation
x4d = torch.ones(3, 5, 2, 2)
y4d = m(x4d)

__init__

Affine.__init__(
  num_features,
  bias=True,
  fix_weight=False,
  fix_bias=False,
  inplace=False
)[source]

Create an AffineChannel module.

Parameters:
  • num_features (int) The number of channels.
  • bias (bool, optional, default=True) True to attach a bias.
  • fix_weight (bool, optional, default=False) True to freeze the weight.
  • fix_bias (bool, optional, default=False) True to freeze the bias.
  • inplace (bool, optional, default=False) Whether to do the operation in-place.