You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2017/08/21 23:19:10 UTC

[incubator-mxnet] branch v0.11.0 updated: Fix optimizer parms in fit.py + Don't repeatedly call slow prepare_mkl.sh script (#7545)

This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch v0.11.0
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/v0.11.0 by this push:
     new c95068b  Fix optimizer parms in fit.py + Don't repeatedly call slow prepare_mkl.sh script (#7545)
c95068b is described below

commit c95068b7b48fe0c1ae460fee982bca46adb0bffd
Author: Chris Olivier <cj...@gmail.com>
AuthorDate: Mon Aug 21 16:19:07 2017 -0700

    Fix optimizer parms in fit.py + Don't repeatedly call slow prepare_mkl.sh script (#7545)
    
    * Only call MKL script once
    
    * Fix 'momentum' and 'multi_precision' optimizer args
    
    * fix working
---
 Makefile                                   |  4 ++--
 example/image-classification/common/fit.py | 13 ++++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 33151e5..77d2004 100644
--- a/Makefile
+++ b/Makefile
@@ -36,8 +36,8 @@ include $(config)
 
 ifeq ($(USE_MKL2017), 1)
 # must run ./prepare_mkl before including mshadow.mk
-	RETURN_STRING = $(shell ./prepare_mkl.sh $(MKLML_ROOT))
-	MKLROOT = $(firstword $(RETURN_STRING))
+	RETURN_STRING := $(shell ./prepare_mkl.sh $(MKLML_ROOT))
+	MKLROOT := $(firstword $(RETURN_STRING))
 	export USE_MKLML = $(lastword $(RETURN_STRING))
 endif
 
diff --git a/example/image-classification/common/fit.py b/example/image-classification/common/fit.py
index 73235fc..dfec2a8 100755
--- a/example/image-classification/common/fit.py
+++ b/example/image-classification/common/fit.py
@@ -163,10 +163,17 @@ def fit(args, network, data_loader, **kwargs):
     lr_scheduler  = lr_scheduler
     optimizer_params = {
             'learning_rate': lr,
-            'momentum' : args.mom,
             'wd' : args.wd,
-            'lr_scheduler': lr_scheduler,
-            'multi_precision': True}
+            'lr_scheduler': lr_scheduler}
+
+    # Add 'multi_precision' parameter only for SGD optimizer
+    if args.optimizer == 'sgd':
+        optimizer_params['multi_precision'] = True
+
+    # Only a limited number of optimizers have 'momentum' property
+    has_momentum = {'sgd', 'dcasgd'}
+    if args.optimizer in has_momentum:
+        optimizer_params['momentum'] = args.mom
 
     monitor = mx.mon.Monitor(args.monitor, pattern=".*") if args.monitor > 0 else None
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].