mindspore/docs/api/api_python/ops/mindspore.ops.SparseApplyAd...

39 lines
2.0 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.SparseApplyAdagrad
================================
.. py:class:: mindspore.ops.SparseApplyAdagrad(lr, update_slots=True, use_locking=False)
根据Adagrad算法更新相关参数。
.. math::
\begin{array}{ll} \\
accum += grad * grad \\
var -= lr * grad * \frac{1}{\sqrt{accum}}
\end{array}
`var``accum``grad` 的输入遵循隐式类型转换规则,使数据类型一致。如果它们具有不同的数据类型,则低精度数据类型将转换为相对最高精度的数据类型。
参数:
- **lr** (float) - 学习率。
- **update_slots** (bool) - 如果为True则将更新 `accum` 。默认值True。
- **use_locking** (bool) - 是否对参数更新加锁保护。默认值False。
输入:
- **var** (Parameter) - 要更新的变量。为任意维度其数据类型为float16或float32。
- **accum** (Parameter) - 要更新的累积。shape和数据类型必须与 `var` 相同。
- **grad** (Tensor) - 梯度为一个Tensor。shape和数据类型必须与 `var` 相同,且需要满足 :math:`grad.shape[1:] = var.shape[1:] if var.shape > 1`
- **indices** (Tensor) - `var``accum` 第一维度的索引向量数据类型为int32且需要保证 :math:`indices.shape[0] = grad.shape[0]`
输出:
2个Tensor组成的tuple更新后的参数。
- **var** (Tensor) - shape和数据类型与 `var` 相同。
- **accum** (Tensor) - shape和数据类型与 `accum` 相同。
异常:
- **TypeError** - 如果 `lr` 不是float类型。
- **TypeError** - 如果 `update_slots` 或者 `use_locking` 不是布尔值。
- **TypeError** - 如果 `var``accum``lr``grad` 的数据类型既不是float16也不是float32。
- **TypeError** - 如果 `indices` 的数据类型不是int32。
- **RuntimeError** - 如果 `var``accum``grad` 不支持数据类型转换。