InstanceNorm

@frozen
public struct InstanceNorm<Scalar> : Layer where Scalar : TensorFlowFloatingPoint

A layer that applies instance normalization over a mini-batch of inputs.

Reference: Instance Normalization: The Missing Ingredient for Fast Stylization.

  • The offset value, also known as beta.

    Declaration

    public var offset: Tensor<Scalar> { get set }
  • The scale value, also known as gamma.

    Declaration

    public var scale: Tensor<Scalar> { get set }
  • The axis where the features lie.

    Declaration

    public var axis: Int { get }
  • The variance epsilon value.

    Declaration

    public var epsilon: Scalar { get }
  • Creates a instance normalization layer.

    Precondition

    The axis cannot be batch axis.

    Precondition

    The offset must have rank 1.

    Precondition

    The offset and the scale must have same shape.

    Declaration

    public init(
      offset: Tensor<Scalar>,
      scale: Tensor<Scalar>,
      axis: Int,
      epsilon: Scalar
    )

    Parameters

    offset

    The initial offset value.

    scale

    The initial scale value.

    axis

    The axis where the features lie.

    epsilon

    The variance epsilon value.

  • Creates a instance normalization layer.

    Precondition

    The axis cannot be batch axis.

    Precondition

    The numbers of features of the input and the offset must be same.

    Declaration

    public init(
      featureCount: Int,
      axis: Int = -1,
      epsilon: Scalar = 1e-3
    )

    Parameters

    featureCount

    The number of features.

    axis

    The axis where the features lie. The default value is -1.

    epsilon

    The small scalar added to variance. The default value is 0.001.

  • Returns the output obtained from applying the layer to the given input.

    Declaration

    @differentiable
    public func forward(_ input: Tensor<Scalar>) -> Tensor<Scalar>

    Parameters

    input

    The input to the layer.

    Return Value

    The output.