ptrendx commented on a change in pull request #7654: Making mixed precision
work with all optimizers
URL: https://github.com/apache/incubator-mxnet/pull/7654#discussion_r141108968
##########
File path: tests/python/unittest/test_optimizer.py
##########
@@ -507,36 +520,33 @@ def test_rms():
opt1 = PyRMSProp
opt2 = mx.optimizer.RMSProp
shape = (3, 4, 5)
- kwargs = [{},
- {'clip_gradient': 0.5},
- {'clip_gradient': 0.4, 'rescale_grad': 0.14},
- {'rescale_grad': 0.8},
- {'clip_gradient': 0.5, 'wd': 0.07},
- {'clip_gradient': 0.4, 'rescale_grad': 0.14, 'wd': 0.03},
- {'rescale_grad': 0.8, 'wd': 0.05},
- {'centered': True},
- {'clip_gradient': 0.5, 'centered': True},
- {'clip_gradient': 0.4, 'rescale_grad': 0.14, 'centered': True},
- {'rescale_grad': 0.8, 'centered': True},
- {'clip_gradient': 0.5, 'wd': 0.07, 'centered': True},
- {'clip_gradient': 0.4, 'rescale_grad': 0.14, 'wd': 0.03,
'centered': True},
- {'rescale_grad': 0.8, 'wd': 0.05, 'centered': True},
- {'clip_gradient': 0.5, 'clip_weights': 0.01},
- {'clip_gradient': 0.4, 'rescale_grad': 0.14, 'clip_weights':
0.01},
- {'rescale_grad': 0.8, 'clip_weights': 0.01},
- {'clip_gradient': 0.5, 'wd': 0.07, 'clip_weights': 0.01},
- {'clip_gradient': 0.4, 'rescale_grad': 0.14, 'wd': 0.03,
'clip_weights': 0.01},
- {'rescale_grad': 0.8, 'wd': 0.05, 'clip_weights': 0.01},
- {'centered': True, 'clip_weights': 0.01},
- {'clip_gradient': 0.5, 'centered': True, 'clip_weights': 0.01},
- {'clip_gradient': 0.4, 'rescale_grad': 0.14, 'centered': True,
'clip_weights': 0.01},
- {'rescale_grad': 0.8, 'centered': True, 'clip_weights': 0.01},
- {'clip_gradient': 0.5, 'wd': 0.07, 'centered': True,
'clip_weights': 0.01},
- {'clip_gradient': 0.4, 'rescale_grad': 0.14, 'wd': 0.03,
'centered': True, 'clip_weights': 0.01},
- {'rescale_grad': 0.8, 'wd': 0.05, 'centered': True,
'clip_weights': 0.01}]
- for kwarg in kwargs:
- compare_optimizer(opt1(**kwarg), opt2(**kwarg), shape, np.float32)
- compare_optimizer(opt1(**kwarg), opt2(**kwarg), shape, np.float32,
g_stype='row_sparse')
+ cg_options = [{}, {'clip_gradient': 0.4}, {'clip_gradient': 0.5}]
+ cw_options = [{}, {'clip_weights': 0.01}]
+ center_options = [{}, {'centered': False}, {'centered': True}]
+ rg_options = [{}, {'rescale_grad': 0.14}, {'rescale_grad': 0.8}]
+ wd_options = [{}, {'wd': 0.03}, {'wd': 0.05}, {'wd': 0.07}]
+ mp_options = [{}, {'multi_precision': False}, {'multi_precision': True}]
+ for dtype in [np.float16, np.float32]:
Review comment:
And that is fine - previously there was a list of test cases where it was
really hard to make sure that all possible combinations of parameters are
tested (and all possible combinations should be tested). This design guarantees
that.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services