mindspore/docs/api/api_python/nn/mindspore.nn.DistributedGra...

25 lines
1.1 KiB
ReStructuredText
Raw Normal View History

2021-12-04 15:18:50 +08:00
mindspore.nn.DistributedGradReducer
===================================
2022-12-30 10:57:10 +08:00
.. py:class:: mindspore.nn.DistributedGradReducer(parameters, mean=None, degree=None, fusion_type=1, group=GlobalComm.WORLD_COMM_GROUP)
2021-12-04 15:18:50 +08:00
分布式优化器。
2022-01-10 16:58:33 +08:00
用于数据并行模式中对所有卡的梯度利用AllReduce进行聚合。
2021-12-04 15:18:50 +08:00
2022-07-22 16:25:38 +08:00
参数:
- **parameters** (list) - 需要更新的参数。
2022-12-30 10:57:10 +08:00
- **mean** (bool) - 当mean为True时对AllReduce之后的梯度求均值。未指定时使用auto_paralel_context中的配置“gradients_mean”。 默认值None。
2022-07-22 16:25:38 +08:00
- **degree** (int) - 平均系数通常等于设备编号。默认值None。
- **fusion_type** (int) - AllReduce算子的融合类型。默认值1。
- **group** (str) - AllReduce算子的通信域若需要自定义通信域需要调用create_group接口。默认值GlobalComm.WORLD_COMM_GROUP。
2021-12-04 15:18:50 +08:00
2022-07-22 16:25:38 +08:00
异常:
- **ValueError** - 如果degree不是int或小于0。
2022-11-08 10:26:50 +08:00
样例:
.. note::
.. include:: ../ops/mindspore.ops.comm_note.rst
该样例需要在多卡环境下运行。