Net

class dragon.vm.caffe.Net(*args)[source]

The base net class to connect layers.

This class accepts a network file, and an optional parameter file.

Besides, a phase tag is required to compute gradients or not:

net1 = caffe.Net('train.prototxt', 'TRAIN')
net2 = caffe.Net('test.prototxt', 'test.caffemodel', 'TEST')

__init__

Net.__init__(*args)[source]

Create a Net.

Parameters:
  • net_file (str) – The path of text proto file to load network.
  • param_file (str, optional) – The path of binary proto file to load parameters.
  • phase ({'TRAIN', 'TEST'}, optional) – The optional phase tag.

Properties

blobs

Net.blobs

Return the blob dict.

Returns:
dict – The blob dict.

inputs

Net.inputs

Return the input blob names.

Returns:
Sequence[str] – The input names.

outputs

Net.outputs

Return the output blob names.

Returns:
Sequence[str] – The output names.

params

Net.params

Return the parameter dict.

Returns:
dict – The parameter dict.

Methods

backward

Net.backward(**diffs)[source]

The backward pass.

Parameters:
  • diffs (dict, optional) – The data to feed to the diffs.

copy_from

Net.copy_from(other)[source]

Copy layers from the other.

Parameters:
  • other (Union[str, NetParameter]) – The path of binary proto file or NetParameter.

forward

Net.forward(**inputs)[source]

The forward pass.

Parameters:
  • inputs (dict, optional) – The data to feed to the inputs.
Returns:

callable – The callable to fetch outputs.

forward_backward

Net.forward_backward(**inputs)[source]

The forward and backward pass.

Parameters:
  • inputs (dict, optional) – The data to feed to the inputs.
Returns:

callable – The callable to fetch outputs.

save

Net.save(filepath)[source]

Save proto into a binary file.

Parameters:
  • filepath (str) – The path of binary proto file.