Chainer
6.0.0b2

Tutorials

  • Chainer at a Glance
  • Concepts Walkthrough

Examples

  • Neural Net Examples
  • Colab Notebook Examples
  • Awesome Chainer

References

  • API Reference
    • Variable and Parameter
    • Functions
    • Link and Chains
      • Learnable connections
      • Activation/loss/normalization functions with parameters
      • Machine learning models
      • Pre-trained models
      • Link and Chain base classes
      • Link hooks
        • chainer.link_hooks.TimerHook
        • chainer.LinkHook
    • Probability Distributions
    • Optimizers
    • Weight Initializers
    • Training Tools
    • Datasets
    • Iterator
    • Serializers
    • Utilities
    • Configuring Chainer
    • Debug Mode
    • Visualization of Computational Graph
    • Static Subgraph Optimizations: Usage
    • Static Subgraph Optimizations: Design Notes
    • Caffe Model Support
    • Assertion and Testing
  • Installation
  • Distributed Deep Learning with ChainerMN

Other

  • API Compatibility Policy
  • Contribution Guide
  • Tips and FAQs
  • Performance Best Practices
  • Upgrade Guide
  • Comparison with Other Frameworks
  • License

Community

  • Slack Chat
  • Forums
Chainer
  • Docs »
  • API Reference »
  • Link and Chains »
  • chainer.link_hooks.TimerHook

chainer.link_hooks.TimerHook¶

class chainer.link_hooks.TimerHook[source]¶

Link hook for measuring elapsed time of forward().

Example

Code example:

from chainer.link_hooks import TimerHook
hook = TimerHook()
with hook:
    trainer.run()
hook.print_report()

Output example:

  LinkName  ElapsedTime  Occurrence
    Linear     41.42sec        2100
       MLP     42.09sec         700
Classifier     42.39sec         700

where LinkName is the name of link that calls the hook, and ElapsedTime is the elapsed time the link consumed, and Occurrence is the number of calls.

Warning

Call graph of links are hierarchical. That means reported elapsed times may be overlapping with each other and the sum may exceed the total time.

Variables

call_history – List of measurement results. It consists of pairs of the name of the link that calls this hook and the elapsed time the forward() method of link consumes.

Methods

__enter__()[source]¶
__exit__(*_)[source]¶
added(link)[source]¶

Callback function invoked when the link hook is registered

Parameters

link (Link) – Link object to which the link hook is registered. None if the link hook is registered globally.

deleted(link)[source]¶

Callback function invoked when the link hook is unregistered

Parameters

link (Link) – Link object to which the link hook is unregistered. None if the link hook had been registered globally.

forward_postprocess(args)[source]¶

Callback function invoked after a forward call of a link.

Parameters

args –

Callback data. It has the following attributes:

  • link (Link)

    Link object.

  • forward_name (str)

    Name of the forward method.

  • args (tuple)

    Non-keyword arguments given to the forward method.

  • kwargs (dict)

    Keyword arguments given to the forward method.

  • out

    Return value of the forward method.

forward_preprocess(args)[source]¶

Callback function invoked before a forward call of a link.

Parameters

args –

Callback data. It has the following attributes:

  • link (Link)

    Link object.

  • forward_name (str)

    Name of the forward method.

  • args (tuple)

    Non-keyword arguments given to the forward method.

  • kwargs (dict)

    Keyword arguments given to the forward method.

print_report(file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]¶

Prints a summary report of time profiling in links.

summary()[source]¶

Returns a summary of time profiling in links.

Returns

A summarized dictionary whose keys are link names and values are dictionaries of elapsed_time and occurrence.

total_time()[source]¶

Returns total elapsed time in seconds.

Attributes

name = 'TimerHook'¶
Next Previous

© Copyright 2015, Preferred Networks, inc. and Preferred Infrastructure, inc.

Built with Sphinx using a theme provided by Read the Docs.