Caffe2 - Python API
A deep learning, cross platform ML framework
Public Member Functions | Public Attributes | List of all members
caffe2.python.task.SetupNets Class Reference
Inheritance diagram for caffe2.python.task.SetupNets:

Public Member Functions

def __init__ (self, init_nets=None, exit_nets=None)
 
def setup (self, init_net)
 
def exit (self, exit_net)
 

Public Attributes

 init_nets
 
 exit_nets
 

Detailed Description

Allow to register a list of nets to be run at initialization
and finalization of Tasks or TaskGroups.
For example, let's say you have the following:

    init_net = core.Net('init')
    my_val = init_net.ConstantFill([], 'my_val', value=0)

    net = core.Net('counter')
    net.Add([my_val, net.Const(1),], [my_val])

    with TaskGroup() as task_group:
        with Node('trainer'):
            my_task = Task(step=[net])

In order to have `init_net` run once before `net` runs for the
first time, you can do one of the following:

    net.add_attribute(Task.TASK_SETUP, SetupNets([init_net]))

or

    net.add_attribute(TaskGroup.LOCAL_SETUP, SetupNets([init_net]))

- With Task.TASK_SETUP, init_net will run once at my_task startup.
- With TaskGroup.LOCAL_SETUP, init_net will run once on node 'trainer',
  before any task of the task group is run on that node.

The same SetupNets object can be added to multiple nets. It will only
run once per Task/TaskGroup run.

Definition at line 637 of file task.py.


The documentation for this class was generated from the following file: