文档反馈

问题文档片段

问题文档片段包含公式时,显示为空格。

提交类型
issue

有点复杂...

找人问问吧。

请选择提交类型

问题类型
规范和低错类

- 规范和低错类:

- 错别字或拼写错误,标点符号使用错误、公式错误或显示异常。

- 链接错误、空单元格、格式错误。

- 英文中包含中文字符。

- 界面和描述不一致,但不影响操作。

- 表述不通顺,但不影响理解。

- 版本号不匹配:如软件包名称、界面版本号。

易用性

- 易用性:

- 关键步骤错误或缺失,无法指导用户完成任务。

- 缺少主要功能描述、关键词解释、必要前提条件、注意事项等。

- 描述内容存在歧义指代不明、上下文矛盾。

- 逻辑不清晰,该分类、分项、分步骤的没有给出。

正确性

- 正确性:

- 技术原理、功能、支持平台、参数类型、异常报错等描述和软件实现不一致。

- 原理图、架构图等存在错误。

- 命令、命令参数等错误。

- 代码片段错误。

- 命令无法完成对应功能。

- 界面错误,无法指导操作。

- 代码样例运行报错、运行结果不符。

风险提示

- 风险提示:

- 对重要数据或系统存在风险的操作,缺少安全提示。

内容合规

- 内容合规:

- 违反法律法规,涉及政治、领土主权等敏感词。

- 内容侵权。

请选择问题类型

问题描述

点击输入详细问题描述,以帮助我们快速定位问题。

mindspore.common.initializer

Initializer for cell parameters.

class mindspore.common.initializer.Constant(value)[source]

Initialize a constant.

Parameters

value (Union[int, numpy.ndarray]) – The value to initialize.

Returns

Array, an array after being assigned.

class mindspore.common.initializer.HeNormal(negative_slope=0, mode='fan_in', nonlinearity='leaky_relu')[source]

Initialize the array with He kaiming Normal algorithm, and from a normal distribution collect samples within N(0, sigma).

Parameters
  • negative_slope (int, float, bool) – Default: 0, used when nonlinearity is ‘leaky_relu’.

  • mode (str) – Default: fan_in.

  • nonlinearity (str) – Default: leaky_relu.

Returns

Array, assigned array.

class mindspore.common.initializer.HeUniform(negative_slope=0, mode='fan_in', nonlinearity='leaky_relu')[source]

Initialize the array with He kaiming uniform algorithm, and from a uniform distribution collect samples within U[-boundary, boundary] The boundary is defined as :

where boundary=6(1+a2)×fan_in.

Parameters
  • negative_slope (int, float, bool) – Default: 0, used when nonlinearity is ‘leaky_relu’.

  • mode (str) – Default: fan_in.

  • nonlinearity (str) – Default: leaky_relu.

Returns

Array, assigned array.

class mindspore.common.initializer.Initializer(**kwargs)[source]

The base class of the initializer. Initialization of tensor basic attributes and model weight values.

Parameters

kwargs (dict) – Keyword arguments for Initializer.

Returns

Array, an array after being initialized.

class mindspore.common.initializer.Normal(sigma=0.01)[source]

Initialize a normal array, and obtain values N(0, sigma) from the uniform distribution to fill the input tensor.

Parameters

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

Returns

Array, normal 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.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.Uniform(scale=0.07)[source]

Initialize a uniform array, and obtain values U(-scale, scale) from the uniform distribution to fill the input tensor.

Parameters

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

Returns

Array, uniform array.

class mindspore.common.initializer.XavierUniform(gain=1)[source]

Initialize the array with xavier uniform algorithm, and from a uniform distribution collect samples within U[-boundary, boundary] The boundary is defined as :

where boundary=gain6nin+nout.

where nin is the number of input units in the weight tensor. where nout is the number of output units in the weight tensor.

Parameters

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

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, an array after being assigned.

mindspore.common.initializer.initializer(init, shape=None, dtype=mindspore.float32)[source]

Create and initialize a tensor.

Parameters
  • init (Union[Tensor, str, Initializer, numbers.Number]) –

    Initialize value.

    • str: The init should be the alias of the class inheriting from Initializer and the corresponding class will be called.

    • Initializer: The init should be the class inheriting from Initializer to initialize tensor.

    • numbers.Number: The Constant will be called to initialize tensor.

  • shape (Union[tuple, list, int]) – A list of integers, a tuple of integers or an integer as the shape of output. Default: None.

  • dtype (mindspore.dtype) – The type of data in initialized tensor. Default: mindspore.float32.

Returns

Union[Tensor, MetaTensor], When init is Tensor, the return is Tensor object, otherwise the return is Initialize object.

Examples

>>> tensor = initializer('ones', [1, 2, 3], mindspore.float32)
>>> tensor = initializer(One(), [1, 2, 3], mindspore.float32)
>>> tensor = initializer(0, [1, 2, 3], mindspore.float32)