mindspore/docs/api/api_python/ops/mindspore.ops.AssignSub.rst

26 lines
1.3 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.AssignSub
=======================
.. py:class:: mindspore.ops.AssignSub
从网络参数减去特定数值来更新网络参数。
输入 `variable``value` 会通过隐式数据类型转换使数据类型保持一致。如果数据类型不同,低精度的数据类型会被转换到高精度的数据类型。如果 `value` 为标量会被自动转换为Tensor其数据类型会与 `variable` 保持一致。
.. Note::
由于 `variable` 类型为 `Parameter` ,其数据类型不能改变。因此只允许 `value` 的数据类型转变为 `variable` 的数据类型。而且由于不同设备支持的转换类型会有所不同,推荐在使用此操作时使用相同的数据类型。
**输入:**
- **variable** (Parameter) - 待更新的网络参数shape: :math:`(N,*)` ,其中 :math:`*` 表示任何数量的附加维度。其轶应小于8。
- **value** (Union[numbers.Number, Tensor]) - 从 `variable` 减去的值。如果类型为Tensor则应与 `variable` 的shape相同。使用此操作时推荐使用相同的数据类型。
**输出:**
Tensorshape和数据类型与 `variable` 相同。
**异常:**
- **TypeError** - `value` 不是标量或Tensor。
- **RuntimeError** - `variable``value` 之间的类型转换不被支持。