This is an automated email from the ASF dual-hosted git repository. jxie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push: new ac4369c update readme (#9005) ac4369c is described below commit ac4369c7d94b1bf8a72c0584553ea7921c9312db Author: Haibin Lin <linhaibin.e...@gmail.com> AuthorDate: Fri Dec 8 20:44:35 2017 -0800 update readme (#9005) --- example/python-howto/README.md | 8 +++++--- example/python-howto/monitor_weights.py | 19 ++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/example/python-howto/README.md b/example/python-howto/README.md index 2499c2a..2965240 100644 --- a/example/python-howto/README.md +++ b/example/python-howto/README.md @@ -1,15 +1,17 @@ Python Howto Examples ===================== -* [Configuring Net to get Multiple Ouputs](multiple_outputs.py) + +* [Configuring Net to Get Multiple Ouputs](multiple_outputs.py) * [Configuring Image Record Iterator](data_iter.py) +* [Monitor Intermediate Outputs in the Network](monitor_weights.py) * Set break point in C++ code of the symbol using gdb under Linux: * Build mxnet with following values: ``` DEBUG=1 - CUDA=0 #to make sure convolution-inl.h will be used - CUDNN=0 #to make sure convolution-inl.h will be used + USE_CUDA=0 # to make sure convolution-inl.h will be used + USE_CUDNN=0 # to make sure convolution-inl.h will be used ``` * run python under gdb: ```gdb --args python debug_conv.py``` diff --git a/example/python-howto/monitor_weights.py b/example/python-howto/monitor_weights.py index a8b2551..ab77b49 100644 --- a/example/python-howto/monitor_weights.py +++ b/example/python-howto/monitor_weights.py @@ -25,6 +25,7 @@ import mxnet as mx import numpy as np import logging +# network data = mx.symbol.Variable('data') fc1 = mx.symbol.FullyConnected(data = data, name='fc1', num_hidden=128) act1 = mx.symbol.Activation(data = fc1, name='relu1', act_type="relu") @@ -34,20 +35,16 @@ fc3 = mx.symbol.FullyConnected(data = act2, name='fc3', num_hidden=10) mlp = mx.symbol.SoftmaxOutput(data = fc3, name = 'softmax') # data - train, val = MNISTIterator(batch_size=100, input_shape = (784,)) -# train - -logging.basicConfig(level=logging.DEBUG) - -model = mx.model.FeedForward( - ctx = mx.cpu(), symbol = mlp, num_epoch = 20, - learning_rate = 0.1, momentum = 0.9, wd = 0.00001) - +# monitor def norm_stat(d): return mx.nd.norm(d)/np.sqrt(d.size) mon = mx.mon.Monitor(100, norm_stat) -model.fit(X=train, eval_data=val, monitor=mon, - batch_end_callback = mx.callback.Speedometer(100, 100)) +# train with monitor +logging.basicConfig(level=logging.DEBUG) +module = mx.module.Module(context=mx.cpu(), symbol=mlp) +module.fit(train_data=train, eval_data=val, monitor=mon, num_epoch=2, + batch_end_callback = mx.callback.Speedometer(100, 100), + optimizer_params=(('learning_rate', 0.1), ('momentum', 0.9), ('wd', 0.00001))) -- To stop receiving notification emails like this one, please contact ['"comm...@mxnet.apache.org" <comm...@mxnet.apache.org>'].