|
def | __init__ (self, name_or_proto) |
|
def | AppendNet (self, net) |
|
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 | GetBlobRef (self, blob_name) |
|
def | Clone (self, name, blob_remap=None, op_id_mask=None, remap_funcs=None, keep_schema=True) |
|
def | ClonePartial (self, name, inputs, outputs, remap_funcs=None) |
|
def | Proto (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 | AddExternalInput (self, inputs) |
|
def | AddExternalOutput (self, outputs) |
|
def | AddScopedExternalInputs (self, inputs) |
|
def | AddScopedExternalOutputs (self, outputs) |
|
def | external_inputs (self) |
|
def | external_outputs (self) |
|
def | set_input_record (self, input_record) |
|
def | set_output_record (self, record) |
|
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 | __getattr__ (self, op_type) |
|
def | Python (self, f, grad_f=None, pass_workspace=False) |
|
Definition at line 1119 of file core.py.
def core.Net.AddGradientOperators |
( |
|
self, |
|
|
|
ys, |
|
|
|
skip = 0 |
|
) |
| |
Add the gradient for operators in the net.
Inputs:
ys: a list or a dictionary specifying what blobs we want to compute
derivatives of. If the input is a list, we will automatically
generate their gradients with all-one values; if the input is a
dictionary, for any dictionary entries that are not None, we will
take the corresponding blobs as their gradients; for all those
that are None, we will auto-fill them with 1.
skip: skips the first n operators. This is provided mainly because a
lot of nets may use the first few operators for data generation
like stuff which really do not need to have gradients.
Outputs:
returns a map from the blob name in the input network to a blob
containing gradient or a GradientSlice in case of sparse gradient
Currently, this is hard-coded for float operators if there are branches
(i.e. a blob is used as input to multiple operators). This is because
the gradient accumulation (Sum) is float only right now.
Definition at line 1543 of file core.py.
def core.Net.ClonePartial |
( |
|
self, |
|
|
|
name, |
|
|
|
inputs, |
|
|
|
outputs, |
|
|
|
remap_funcs = None |
|
) |
| |
Clone this net, including only ops that are necessary in order to
compute `outputs` given `inputs`. Return references to the cloned
outputs. Internal blobs (blobs that are produced and consumed inside
the net but not used as outputs) will be remapped to avoid name
conflict.
Args:
name: the name of the cloned net
inputs: map where the keys correspond to BlobReferences in the
original net, and the values correspond to external inputs
in the partially cloned net. If `inputs` is a list, don't
remap input names.
outputs: outputs to be produced by the cloned net.
Returns:
Tuple (new_net, new_outputs)
new_net: a new Net object.
new_outputs: list of BlobReferences corresponding to the
outputs produced by new_net.
Definition at line 1394 of file core.py.
def core.Net.Python |
( |
|
self, |
|
|
|
f, |
|
|
|
grad_f = None , |
|
|
|
pass_workspace = False |
|
) |
| |
Registers and returns a python operator.
`f` and `f_grad` 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.
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.
Definition at line 1726 of file core.py.