Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix optimizer parms in fit.py + Don't repeatedly call slow prepare_mkl.sh script #7545

Merged
merged 3 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 10 additions & 3 deletions example/image-classification/common/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down