Initializer

dragon.operators.initializer.Fill(shape, value=0, dtype='float32', **kwargs)

Return a Tensor with specific value filled.

Type Constraints: (bool, int8, uint8, int32, int64, float16, float32, float64)

Parameters:
  • shape (sequence of (int, Tensor)) – The output shape.
  • value (number, optional) – The value to fill.
  • dtype (str, optional) – The optional data type.
Returns:

A tensor filled with the constants.

Return type:

Tensor

dragon.operators.initializer.RandomUniform(shape, low=-1.0, high=1.0, **kwargs)

Return a Tensor randomly initialized with Uniform distribution.

Type Constraints: float32

Parameters:
  • shape (sequence of (int, Tensor)) – The shape of the new tensor.
  • low (number, optional) – The lower bound of uniform distribution.
  • high (number, optional) – The higher bound of uniform distribution.
Returns:

A randomly initialized tensor.

Return type:

Tensor

dragon.operators.initializer.RandomNormal(shape, mean=0.0, std=1.0, **kwargs)

Return a Tensor randomly initialized with Normal distribution.

Type Constraints: float32

Parameters:
  • shape (sequence of (int, Tensor)) – The shape of the new tensor.
  • mean (number, optional) – The mean(mu) of normal distribution.
  • std (number, optional) – The std(sigma) of normal distribution.
Returns:

A randomly initialized tensor.

Return type:

Tensor

dragon.operators.initializer.TruncatedNormal(shape, mean=0.0, std=1.0, **kwargs)

Return a Tensor randomly initialized with Truncated Normal distribution.

The bounds of truncated distribution are \(\\ (\mu - 2\sigma, \mu + 2\sigma)\).

Type Constraints: float32

Parameters:
  • shape (sequence of (int, Tensor)) – The shape of the new tensor.
  • mean (number, optional) – The mean(mu) of normal distribution.
  • std (number, optional) – The std(sigma) of normal distribution.
Returns:

A randomly initialized tensor.

Return type:

Tensor

dragon.operators.initializer.GlorotUniform(shape, scale=3.0, mode='FAN_IN', **kwargs)

Return a Tensor randomly initialized with Xavier Uniform distribution.

The bounds of uniform distribution are \(\\ (-\sqrt{\frac{Scale}{Fan}}, \sqrt{\frac{Scale}{Fan}})\).

Type Constraints: float32

Parameters:
  • shape (sequence of (int, Tensor)) – The shape of the new tensor.
  • scale (number, optional) – The scale of xavier uniform distribution.
  • mode ({'FAN_IN', 'FAN_OUT', 'FAN_AVG'}, optional) – The mode to compute the normalizer.
Returns:

A randomly initialized tensor.

Return type:

Tensor

dragon.operators.initializer.GlorotNormal(shape, scale=2.0, mode='FAN_IN', **kwargs)

Return a Tensor randomly initialized with Kaiming Normal distribution.

The parameters of normal distribution are \(\\ (\mu = 0, \sigma = \sqrt{\frac{Scale}{Fan}})\).

Type Constraints: float32

Parameters:
  • shape (list, tuple or Tensor) – The shape of the new tensor.
  • scale (number, optional) – The scale of msra normal distribution.
  • mode ({'FAN_IN', 'FAN_OUT', 'FAN_AVG'}, optional) – The mode to compute the normalizer.
Returns:

A randomly initialized tensor.

Return type:

Tensor