Copy master parameters to model parameters. Args: model_params: List of model parameters created by :func:`prep_param_lists`. master_params: List of FP32 master parameters created by :func:`prep_param_lists`. If ``master_params`` was created with
(model_params, master_params, flat_master=False)
| 308 | |
| 309 | |
| 310 | def master_params_to_model_params(model_params, master_params, flat_master=False): |
| 311 | """ |
| 312 | Copy master parameters to model parameters. |
| 313 | |
| 314 | Args: |
| 315 | model_params: List of model parameters created by :func:`prep_param_lists`. |
| 316 | master_params: List of FP32 master parameters created by |
| 317 | :func:`prep_param_lists`. If ``master_params`` was created with |
| 318 | ``flat_master=True``, ``flat_master=True`` should also be supplied |
| 319 | to :func:`master_params_to_model_params`. |
| 320 | """ |
| 321 | if flat_master: |
| 322 | for model, master in zip(model_params, |
| 323 | _unflatten_dense_tensors(master_params[0].data, |
| 324 | model_params)): |
| 325 | model.data.copy_(master) |
| 326 | else: |
| 327 | for model, master in zip(model_params, master_params): |
| 328 | model.data.copy_(master.data) |
| 329 | |
| 330 | # Backward compatibility fixes |
| 331 |
no outgoing calls
no test coverage detected