|
def | __init__ (self, name_or_proto) |
|
def | AppendNet (self, net, device_option=None) |
|
def | LogInfo (self, msg_or_blobs) |
|
def | add_attribute (self, name, obj) |
|
def | get_attributes (self, name) |
|
def | set_rand_seed (self, seed=100, sequence_seed=True, seed_on_op_def=False) |
|
def | Name (self) |
|
def | __str__ (self) |
|
def | Const (self, array, blob_out=None, dtype=None) |
|
def | BlobIsDefined (self, blob) |
|
def | UsesBlob (self, blob) |
|
def | UsedBlobNames (self) |
|
def | GetBlobRef (self, blob_name) |
|
def | Clone (self, name, blob_remap=None, op_id_mask=None, remap_funcs=None, keep_schema=True, update_external_list=False) |
|
def | ClonePartial (self, name, inputs, outputs, remap_funcs=None) |
|
def | Proto (self) |
|
def | insert_op_at_idx (self, op, op_idx) |
|
def | reroute_tensor (self, tensor, new_producer, can_modify=None) |
|
def | PopulateProtoWithFileName (self) |
|
def | NextScopedBlob (self, prefix='unnamed') |
|
def | NextBlob (self, prefix='unnamed') |
|
def | NextName (self, prefix=None, output_id=None) |
|
def | AddGradientOperators (self, ys, skip=0) |
|
def | AddArgument (self, arg_name, arg_value) |
|
def | AddExternalInput (self, inputs) |
|
def | AddExternalOutput (self, outputs) |
|
def | AddScopedExternalInputs (self, inputs) |
|
def | AddScopedExternalOutputs (self, outputs) |
|
def | AddObserver (self, observer_type) |
|
def | RemoveObserver (self, observer) |
|
def | NumObservers (self) |
|
def | external_inputs (self) |
|
def | external_outputs (self) |
|
def | set_input_record (self, input_record) |
|
def | recover_input_record_by_prefix (self, prefix) |
|
def | set_output_record (self, record) |
|
def | recover_output_record_by_prefix (self, prefix) |
|
def | AppendOutputRecordField (self, field_name, record) |
|
def | input_record (self) |
|
def | output_record (self) |
|
def | AddExternalInputs (self, inputs) |
|
def | AddExternalOutputs (self, outputs) |
|
def | DeduplicateGradientSlices (self, g, aggregator='sum') |
|
def | RunAllOnGPU (self, gpu_id=0, use_cudnn=False) |
|
def | RunAllOnMKL (self) |
|
def | RunAllOnIDEEP (self) |
|
def | __getattr__ (self, op_type) |
|
def | __dir__ (self) |
|
def | Python (self, f, grad_f=None, python_func_type=None, pass_workspace=False, grad_output_indices=None, grad_input_indices=None) |
|
def | is_external_input (self, blob) |
|
def | extend_ops (self, new_ops) |
|
Definition at line 1395 of file core.py.
def caffe2.python.core.Net.Python |
( |
|
self, |
|
|
|
f, |
|
|
|
grad_f = None , |
|
|
|
python_func_type = None , |
|
|
|
pass_workspace = False , |
|
|
|
grad_output_indices = None , |
|
|
|
grad_input_indices = None |
|
) |
| |
Registers and returns a python operator.
`f` and `grad_f` can be one of the following:
- a function with signature (inputs, outputs), where inputs and
outputs are a list of CPUTensor objects. This function will be
called from C++ everytime the operator is executed.
- a tuple (func, args, kwargs), here `func` is a callable, args is
an argument list, and kwargs is a dict list. The call:
f = func(*args, kwargs)
will be performed locally at node initialization time, on all of
the nodes of the job, returning `f`, a callable that will be used
as the python operator function to be called during Net execution.
This is to be used when using python operator in a distributed
context, and allows to create and keep local python state across
calls to the operator.
`python_func_type` is a type of an object that constructed as
python_func_type(f) and provides an implementation to forward and
backward functions. Its useful in such a case where users needs
a statefull PythonOp (ex: use autograd for computing grad_f).
If `pass_workspace` is True, the signature is changed to
(inputs, outputs, workspace) where `workspace` is the workspace the op
is going to run on. This is potentially dangerous (as the op can
manipulate the workspace directly), use on your own risk.
If a gradient function is specified (`grad_f`), by default its inputs
will be: (1) all inputs to `f`, (2) followed by all outputs of `f`, (3)
and then all gradient outputs of `f`. The outputs of `grad_f` will be
(by default) all gradient inputs to `f`. If a subset of the gradient
outputs or gradient inputs is desired instead, then the subsets can be
specified by providing `grad_output_indices` and/or `grad_input_indices`
which identify the indices of `f`'s inputs and outputs which have
gradients.
Definition at line 2219 of file core.py.