Public Member Functions
ie_api.IENetwork Class Reference

This class contains the information about the network model read from IR and allows you to manipulate with some model parameters such as layers affinity and output layers. More...

Public Member Functions

def __init__
 Class constructor. More...

 
 
 
 
 
 
 
 
 
def from_ir
 
def add_outputs (self, outputs)
 Marks any intermediate layer as output layer to retrieve the inference results from the specified layers. More...

 
def serialize (self, path_to_xml, path_to_bin="")
 Serializes the network and stores it in files. More...

 
def reshape (self, input_shapes)
 Reshapes the network to change spatial dimensions, batch size, or any dimension. More...

 

Class Attributes

name
Name of the loaded network.
inputs

A dictionary that maps input layer names to DataPtr objects.

outputs
A dictionary that maps output layer names to DataPtr objects.
batch_size

Batch size of the network.

Provides getter and setter interfaces to get and modify the network batch size. For example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
print(net.batch_size)
net.batch_size = 4
print(net.batch_size)
print(net.inputs['data'].shape)
precision
Note
This property is deprecated: network precision does not make sense, use precision on edges.

Precision of the network

layers
Return dictionary that maps network layer names in topological order to IENetLayer objects containing layer properties.
stats
Note
This property is deprecated. New Calibration Tool doesn't generate statistics

Returns LayersStatsMap object containing dictionary that maps network layer names to calibration statistics represented by LayerStats objects.

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
net.stats.update({"conv1_2d" : LayserStats(min=(-25, -1, 0), max=(63, 124, 70)),
"conv2_2d" : LayserStats(min=(-5, -1, 0, 1, -7, 2), max=(63, 124, 70, 174, 99, 106))
})

Detailed Description

This class contains the information about the network model read from IR and allows you to manipulate with some model parameters such as layers affinity and output layers.

Constructor & Destructor Documentation

§ __init__()

def ie_api.IENetwork.__init__ (   self,
  model 
)

Class constructor.

Note
Reading networks using IENetwork constructor is deprecated. Please, use IECore.read_network() method instead.
Parameters
modelA .xml file of the IR or PyCapsule containing smart pointer to nGraph function. In case of passing a .xml file attribute value can be a string path or bytes with file content depending on init_from_buffer attribute value
weightsA .bin file of the IR. Depending on init_from_buffer value, can be a string path or bytes with file content.
init_from_bufferDefines the way of how model and weights attributes are interpreted. If False, attributes are interpreted as strings with paths to .xml and .bin files of IR. If True, they are interpreted as Python bytes object with .xml and .bin files content. Ignored in case of IENetwork object initialization from nGraph function.
Returns
Instance of IENetwork class

Usage example:

Initializing IENetwork object from IR files:

net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)

Initializing IENetwork object bytes with content of IR files:

with open(path_to_bin_file, 'rb') as f:
bin = f.read()
with open(path_to_xml_file, 'rb') as f:
xml = f.read()
net = IENetwork(model=xml, weights=bin, init_from_buffer=True)

Member Function Documentation

§ add_outputs()

def ie_api.IENetwork.add_outputs (   self,
  outputs 
)

Marks any intermediate layer as output layer to retrieve the inference results from the specified layers.

Parameters
outputsList of layers to be set as model outputs. The list can contain strings with layer names to be set as outputs or tuples with layer name as first element and output port id as second element. In case of setting one layer as output, string or tuple with one layer can be provided.
Returns
None

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
net.add_outputs(["conv5_1', conv2_1', (split_2, 1)])]

§ from_ir()

def ie_api.IENetwork.from_ir (   cls,
  model,
  weights 
)
Note
The function is deprecated. Please use the IENetwork() class constructor to create valid instance of IENetwork.

Reads the model from the .xml and .bin files of the IR.

Parameters
modelPath to .xml file of the IR
weightsPath to .bin file of the IR
Returns
An instance of the IENetwork class

§ reshape()

def ie_api.IENetwork.reshape (   self,
  input_shapes 
)

Reshapes the network to change spatial dimensions, batch size, or any dimension.

Note
Before using this method, make sure that the target shape is applicable for the network. Changing the network shape to an arbitrary value may lead to unpredictable behaviour.
Parameters
input_shapesA dictionary that maps input layer names to tuples with the target shape
Returns
None

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
input_layer = next(iter(net.inputs))
n, c, h, w = net.inputs[input_layer]
net.reshape({input_layer: (n, c, h*2, w*2)}]

§ serialize()

def ie_api.IENetwork.serialize (   self,
  path_to_xml,
  path_to_bin = "" 
)

Serializes the network and stores it in files.

Parameters
path_to_xmlPath to a file, where a serialized model will be stored
path_to_binPath to a file, where serialized weights will be stored
Returns
None

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml, weights=path_to_bin)
net.serialize(path_to_xml, path_to_bin)