mxnet.monitor

Monitor outputs, weights, and gradients for debugging.

Classes

Monitor(interval[, stat_func, pattern, …])

Monitor inputs, outputs, weights, and gradients for debugging.

class mxnet.monitor.Monitor(interval, stat_func=None, pattern='.*', sort=False, monitor_all=False)[source]

Bases: object

Monitor inputs, outputs, weights, and gradients for debugging.

Parameters
  • interval (int) – Number of batches between printing.

  • stat_func (function) – A function that computes statistics of tensors. Takes an NDArray and returns an NDArray. Defaults to mean absolute value abs(x)/size(x).

  • pattern (str) – A regular expression specifying which tensors to monitor. Only tensors with names that match name_pattern will be included. For example, ‘.*weight|.*output’ will print all weights and outputs and ‘.*backward.*’ will print all gradients.

  • monitor_all (bool, default False) – If true, monitor both input and output, otherwise monitor output only.

Methods

install(exe)

install callback to executor.

tic()

Start collecting stats for current batch.

toc()

End collecting for current batch and return results.

toc_print()

End collecting and print results.

install(exe)[source]

install callback to executor. Supports installing to multiple exes.

Parameters

exe (mx.executor.Executor) – The Executor (returned by symbol.bind) to install to.

tic()[source]

Start collecting stats for current batch. Call before calling forward.

toc()[source]

End collecting for current batch and return results. Call after computation of current batch.

Returns

res

Return type

list of

toc_print()[source]

End collecting and print results.