You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.FTRL.rst 3.6 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. mindspore.nn.FTRL
  2. =================
  3. .. py:class:: mindspore.nn.FTRL(*args, **kwargs)
  4. FTRL算法实现。
  5. FTRL是一种在线凸优化算法,根据损失函数自适应地选择正则化函数。详见论文 `Adaptive Bound Optimization for Online Convex Optimization <https://arxiv.org/abs/1002.4908>`_。工程文档参阅 `Ad Click Prediction: a View from the Trenches <https://www.eecs.tufts.edu/~dsculley/papers/ad-click-prediction.pdf>`_。
  6. 更新公式如下:
  7. .. math::
  8. \begin{array}{ll} \\
  9. m_{t+1} = m_{t} + g^2 \\
  10. u_{t+1} = u_{t} + g - \frac{m_{t+1}^\text{-p} - m_{t}^\text{-p}}{\alpha } * \omega_{t} \\
  11. \omega_{t+1} =
  12. \begin{cases}
  13. \frac{(sign(u_{t+1}) * l1 - u_{t+1})}{\frac{m_{t+1}^\text{-p}}{\alpha } + 2 * l2 }
  14. & \text{ if } |u_{t+1}| > l1 \\
  15. 0.0
  16. & \text{ otherwise }
  17. \end{cases}\\
  18. \end{array}
  19. :math:`m` 表示累加器,:math:`g` 表示 `grads`, :math:`t` 表示当前step,:math:`u` 表示需要更新的线性系数,:math:`p` 表示 `lr_power`,:math:`\alpha` 表示 `learning_rate` ,:math:`\omega` 表示 `params` 。
  20. .. note::
  21. .. include:: mindspore.nn.optim_note_sparse.rst
  22. .. include:: mindspore.nn.optim_note_weight_decay.rst
  23. **参数:**
  24. - **params** (Union[list[Parameter], list[dict]]) - 必须是 `Parameter` 组成的列表或字典组成的列表。当列表元素是字典时,字典的键可以是"params"、"lr"、"weight_decay"、"grad_centralization"和"order_params":
  25. .. include:: mindspore.nn.optim_group_param.rst
  26. - **lr** - 学习率当前不支持参数分组。
  27. .. include:: mindspore.nn.optim_group_dynamic_weight_decay.rst
  28. .. include:: mindspore.nn.optim_group_gc.rst
  29. .. include:: mindspore.nn.optim_group_order.rst
  30. - **initial_accum** (float) - 累加器 `m` 的初始值,必须大于等于零。默认值:0.1。
  31. - **learning_rate** (float) - 学习速率值必须为零或正数,当前不支持动态学习率。默认值:0.001。
  32. - **lr_power** (float) - 学习率的幂值,控制训练期间学习率的下降方式,必须小于或等于零。如果lr_power为零,则使用固定的学习率。默认值:-0.5。
  33. - **l1** (float):l1正则化强度,必须大于等于零。默认值:0.0。
  34. - **l2** (float):l2正则化强度,必须大于等于零。默认值:0.0。
  35. - **use_locking** (bool) - 如果为True,则更新操作使用锁保护。默认值:False。
  36. .. include:: mindspore.nn.optim_arg_loss_scale.rst
  37. - **weight_decay** (Union[float, int, Cell]) - 权重衰减(L2 penalty)。默认值:0.0。
  38. .. include:: mindspore.nn.optim_arg_dynamic_wd.rst
  39. **输入:**
  40. **grads** (tuple[Tensor]) - 优化器中 `params` 的梯度,shape与优化器中的 `params` 相同。
  41. **输出:**
  42. tuple[Parameter],更新的参数,shape与 `params` 相同。
  43. **异常:**
  44. - **TypeError** - `initial_accum`、`learning_rate`、`lr_power`、`l1`、`l2` 或 `loss_scale` 不是float。
  45. - **TypeError** - `parameters` 的元素不是Parameter或dict。
  46. - **TypeError** - `weight_decay` 不是float或int。
  47. - **TypeError** - `use_nesterov` 不是bool。
  48. - **ValueError** - `lr_power` 大于0。
  49. - **ValueError** - `loss_scale` 小于等于0。
  50. - **ValueError** - `initial_accum`、`l1` 或 `l2` 小于0。
  51. .. include:: mindspore.nn.optim_target_unique_for_sparse.rst