mindspore.common.initializer

Initializer for cell parameters.

  • class mindspore.common.initializer.Initializer(**kwargs)[source]
  • The base class of the initializer.

    • Parameters
    • kwargs (dict) – Keyword arguments for Initializer.

    • Returns

    • Array, assigned array.
  • mindspore.common.initializer.initializer(init, shape=None, dtype=mindspore.float32)[source]
  • Create and initialize a tensor.

    • Parameters
    • Returns

    • Tensor, initialized tensor.

Examples

  1. Copy>>> tensor = initializer('ones', [1, 2, 3], mstype.float32)
  • class mindspore.common.initializer.TruncatedNormal(sigma=0.01)[source]
  • Initialize a truncated normal distribution which is a bounded normal distribution within N(low, high).

    • Parameters
    • sigma (float) – The sigma of the array. Default: 0.01.

    • Returns

    • Array, truncated normal array.
  • class mindspore.common.initializer.Normal(sigma=0.01)[source]
  • Initialize a normal array, and obtain values N(0, sigma) from the uniform distributionto fill the input tensor.

    • Parameters
    • sigma (float) – The sigma of the array. Default: 0.01.

    • Returns

    • Array, normal array.
  • class mindspore.common.initializer.Uniform(scale=0.07)[source]
  • Initialize a uniform array, and obtain values U(-scale, scale) from the uniform distributionto fill the input tensor.

    • Parameters
    • scale (float) – The scale of the array. Default: 0.07.

    • Returns

    • Array, uniform array.
  • class mindspore.common.initializer.HeUniform(**kwargs)[source]
  • Initialize the array with He kaiming uniform algorithm, and from a uniform distribution collect samples withinU[-boundary, boundary] where

mindspore.common.initializer - 图1
where
mindspore.common.initializer - 图2
is the number ofinput units in the weight tensor.

  • Parameters
  • arr (Array) – The array to be assigned.

  • Returns

  • Array, assigned array.
  • class mindspore.common.initializer.XavierUniform(gain=1)[source]
  • Initialize the array with xavier uniform algorithm, and from a uniform distribution collect samples withinU[-boundary, boundary] where

mindspore.common.initializer - 图3
.

  • Parameters
  • gain (Array) – The array to be assigned. Default: 1.

  • Returns

  • Array, assigned array.
  • class mindspore.common.initializer.One(**kwargs)[source]
  • Initialize the array to one.

    • Parameters
    • arr (Array) – The array to be assigned.

    • Returns

    • Array, assigned array.
  • class mindspore.common.initializer.Zero(**kwargs)[source]
  • Initialize the array to zero.

    • Parameters
    • arr (Array) – The array to be assigned.

    • Returns

    • Array, assigned array.