(self, params, config, clip_norm=1.0)
| 211 | """ |
| 212 | |
| 213 | def __init__(self, params, config, clip_norm=1.0): |
| 214 | super(ClipByGlobalNorm, self).__init__() |
| 215 | self.global_norm = GlobalNorm(params, config) |
| 216 | self.clip_norm = Tensor([clip_norm], mstype.float32) |
| 217 | self.hyper_map = C.HyperMap() |
| 218 | if config.param_init_type == mstype.float16 and config.enable_offload: |
| 219 | self.enable_grad_fp16 = True |
| 220 | else: |
| 221 | self.enable_grad_fp16 = False |
| 222 | |
| 223 | def construct(self, grads): |
| 224 | """Clip grads by global norm construct""" |
nothing calls this directly
no test coverage detected