diff --git a/Makefile b/Makefile index b6c5834a566b..300f901bd662 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 73235fc2e4ef..dfec2a886b80 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