Table of Contents

Class Net

Namespace
Emgu.CV.Dnn
Assembly
Emgu.CV.dll

This class allows to create and manipulate comprehensive artificial neural networks.

public class Net : UnmanagedObject, IDisposable
Inheritance
Net
Implements
Inherited Members

Constructors

Net()

Default constructor.

public Net()

Properties

Empty

Returns true if there are no layers in the network.

public bool Empty { get; }

Property Value

bool

LayerNames

Return the LayerNames

public string[] LayerNames { get; }

Property Value

string[]

UnconnectedOutLayers

Returns indexes of layers with unconnected outputs.

public int[] UnconnectedOutLayers { get; }

Property Value

int[]

UnconnectedOutLayersNames

Returns names of layers with unconnected outputs.

public string[] UnconnectedOutLayersNames { get; }

Property Value

string[]

Methods

Connect(string, string)

Connects output of the first layer to input of the second layer.

public void Connect(string outPin, string inPin)

Parameters

outPin string

Descriptor of the first layer output.

inPin string

Descriptor of the second layer input.

Remarks

Descriptors have the following template <layer_name>[.input_number]: The first part of the template layer_name is string name of the added layer. If this part is empty then the network input pseudo layer will be used; the second optional part of the template input_number is either number of the layer input, either label one. If this part is omitted then the first layer input will be used.

DisposeObject()

Release the memory associated with this network.

protected override void DisposeObject()

Dump()

Dump net to String

public string Dump()

Returns

string

String with structure, hyperparameters, backend, target and fusion Call method after setInput(). To see correct backend, target and fusion run after forward().

DumpToFile(string)

Dump net structure, hyperparameters, backend, target and fusion to dot file

public void DumpToFile(string path)

Parameters

path string

Path to output file with .dot extension

EnableFusion(bool)

Enables or disables layer fusion in the network.

public void EnableFusion(bool value)

Parameters

value bool

The value

EnableWinograd(bool)

Enables or disables the Winograd compute branch. The Winograd compute branch can speed up 3x3 Convolution at a small loss of accuracy.

public void EnableWinograd(bool value)

Parameters

value bool

The value

Forward(IOutputArrayOfArrays, string)

Runs forward pass to compute output of layer with name outputName.

public void Forward(IOutputArrayOfArrays outputBlobs, string outputName = "")

Parameters

outputBlobs IOutputArrayOfArrays

Contains all output blobs for specified layer.

outputName string

Name for layer which output is needed to get

Forward(IOutputArrayOfArrays, string[])

Runs forward pass to compute outputs of layers listed in outBlobNames.

public void Forward(IOutputArrayOfArrays outputBlobs, string[] outBlobNames)

Parameters

outputBlobs IOutputArrayOfArrays

Contains blobs for first outputs of specified layers.

outBlobNames string[]

Names for layers which outputs are needed to get

Forward(string)

Runs forward pass for the whole network.

public Mat Forward(string outputName = "")

Parameters

outputName string

name for layer which output is needed to get

Returns

Mat

blob for first output of specified layer

GetLayer(int)

Returns layer with specified id which the network use.

public Layer GetLayer(int layerId)

Parameters

layerId int

The id of the layer

Returns

Layer

Layer with specified id which the network use.

GetLayer(string)

Returns layer with specified name which the network use.

public Layer GetLayer(string layerName)

Parameters

layerName string

The name of the layer

Returns

Layer

Layer with specified name which the network use.

GetLayerId(string)

Converts string name of the layer to the integer identifier.

public int GetLayerId(string layerName)

Parameters

layerName string

The name of the layer

Returns

int

The id of the layer

GetPerfProfile(VectorOfDouble)

Returns overall time for inference and timings (in ticks) for layers. Indexes in returned vector correspond to layers ids. Some layers can be fused with others, in this case zero ticks count will be return for that skipped layers. Supported by DNN_BACKEND_OPENCV on DNN_TARGET_CPU only.

public long GetPerfProfile(VectorOfDouble timings = null)

Parameters

timings VectorOfDouble

Vector for tick timings for all layers.

Returns

long

Overall ticks for model inference.

SetHalideScheduler(string)

Schedule layers that support Halide backend. Then compile them for specific target. For layers that not represented in scheduling file or if no manual scheduling used at all, automatic scheduling will be applied.

public void SetHalideScheduler(string s)

Parameters

s string

The value

SetInput(IInputArray, string, double, MCvScalar)

Sets the new value for the layer output blob.

public void SetInput(IInputArray blob, string name = "", double scaleFactor = 1, MCvScalar mean = default)

Parameters

blob IInputArray

Input blob

name string

Descriptor of the updating layer output blob.

scaleFactor double

An optional normalization scale.

mean MCvScalar

An optional mean subtraction values.

SetPreferableBackend(Backend)

Ask network to use specific computation backend where it supported.

public void SetPreferableBackend(Backend value)

Parameters

value Backend

The value

SetPreferableTarget(Target)

Ask network to make computations on specific target device.

public void SetPreferableTarget(Target value)

Parameters

value Target

The value