Public Member Functions | Data Fields
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__ (self, model, weights, init_from_buffer)
 Class constructor. More...
 
def name (self)
 Name of the loaded network.
 
def input_info (self)
 A dictionary that maps input layer names to InputInfoPtr objects.
 
def inputs (self)
 
def outputs (self)
 A dictionary that maps output layer names to DataPtr objects.
 
def batch_size (self)
 Batch size of the network. More...
 
def batch_size (self, batch)
 
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...
 

Data Fields

 name
 Name of the loaded network.
 
 input_info
 A dictionary that maps input layer names to InputInfoPtr objects.
 
 inputs
 
 outputs
 A dictionary that maps output layer names to DataPtr objects.
 
 batch_size
 Batch size of the network. More...
 

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,
  weights,
  init_from_buffer 
)

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)])]

◆ batch_size()

def ie_api.IENetwork.batch_size (   self)

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.input_info['data'].input_data.shape)

◆ inputs()

def ie_api.IENetwork.inputs (   self)
Note
The property is deprecated. Please use the input_info property to get the map of inputs

A dictionary that maps input layer names to DataPtr objects

◆ 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.input_info))
n, c, h, w = net.input_info[input_layer].input_data.shape
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)

Field Documentation

◆ batch_size

ie_api.IENetwork.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.input_info['data'].input_data.shape)

◆ inputs

ie_api.IENetwork.inputs
Note
The property is deprecated. Please use the input_info property to get the map of inputs

A dictionary that maps input layer names to DataPtr objects


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