OpenCV  3.2.0
Open Source Computer Vision
Public Member Functions | Public Attributes | List of all members
cv::dnn::Layer Class Referenceabstract

This interface class allows to build new Layers - are building blocks of networks. More...

#include "dnn.hpp"

Inheritance diagram for cv::dnn::Layer:
cv::dnn::AbsLayer cv::dnn::BaseConvolutionLayer cv::dnn::BNLLLayer cv::dnn::ConcatLayer cv::dnn::CropLayer cv::dnn::EltwiseLayer cv::dnn::InnerProductLayer cv::dnn::LRNLayer cv::dnn::LSTMLayer cv::dnn::MVNLayer cv::dnn::PoolingLayer cv::dnn::PowerLayer cv::dnn::ReLULayer cv::dnn::ReshapeLayer cv::dnn::RNNLayer cv::dnn::SigmoidLayer cv::dnn::SliceLayer cv::dnn::SoftmaxLayer cv::dnn::SplitLayer cv::dnn::TanHLayer

Public Member Functions

 Layer ()
 
 Layer (const LayerParams &params)
 Initializes only name, type and blobs fields. More...
 
virtual ~Layer ()
 
virtual void allocate (const std::vector< Blob *> &input, std::vector< Blob > &output)=0
 Allocates internal buffers and output blobs with respect to the shape of inputs. More...
 
void allocate (const std::vector< Blob > &inputs, std::vector< Blob > &outputs)
 
std::vector< Bloballocate (const std::vector< Blob > &inputs)
 
virtual void forward (std::vector< Blob *> &input, std::vector< Blob > &output)=0
 Given the input blobs, computes the output blobs. More...
 
void forward (const std::vector< Blob > &inputs, std::vector< Blob > &outputs)
 
virtual int inputNameToIndex (String inputName)
 Returns index of input blob into the input array. More...
 
virtual int outputNameToIndex (String outputName)
 Returns index of output blob in output array. More...
 
void run (const std::vector< Blob > &inputs, std::vector< Blob > &outputs)
 Allocates layer and computes output. More...
 
void setParamsFrom (const LayerParams &params)
 Initializes only name, type and blobs fields. More...
 

Public Attributes

std::vector< Blobblobs
 List of learned parameters must be stored here to allow read them by using Net::getParam(). More...
 
String name
 Name of the layer instance, can be used for logging or other internal purposes. More...
 
String type
 Type name which was used for creating layer by layer factory. More...
 

Detailed Description

This interface class allows to build new Layers - are building blocks of networks.

Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs. Also before using the new layer into networks you must register your layer by using one of LayerFactory macros.

Constructor & Destructor Documentation

§ Layer() [1/2]

cv::dnn::Layer::Layer ( )

§ Layer() [2/2]

cv::dnn::Layer::Layer ( const LayerParams params)
explicit

Initializes only name, type and blobs fields.

§ ~Layer()

virtual cv::dnn::Layer::~Layer ( )
virtual

Member Function Documentation

§ allocate() [1/3]

virtual void cv::dnn::Layer::allocate ( const std::vector< Blob *> &  input,
std::vector< Blob > &  output 
)
pure virtual

Allocates internal buffers and output blobs with respect to the shape of inputs.

Parameters
[in]inputvector of already allocated input blobs
[out]outputvector of output blobs, which must be allocated

This method must create each produced blob according to shape of input blobs and internal layer params. If this method is called first time then output vector consists from empty blobs and its size determined by number of output connections. This method can be called multiple times if size of any input blob was changed.

§ allocate() [2/3]

void cv::dnn::Layer::allocate ( const std::vector< Blob > &  inputs,
std::vector< Blob > &  outputs 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ allocate() [3/3]

std::vector<Blob> cv::dnn::Layer::allocate ( const std::vector< Blob > &  inputs)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ forward() [1/2]

virtual void cv::dnn::Layer::forward ( std::vector< Blob *> &  input,
std::vector< Blob > &  output 
)
pure virtual

Given the input blobs, computes the output blobs.

Parameters
[in]inputthe input blobs.
[out]outputallocated output blobs, which will store results of the computation.

Implemented in cv::dnn::RNNLayer, and cv::dnn::LSTMLayer.

§ forward() [2/2]

void cv::dnn::Layer::forward ( const std::vector< Blob > &  inputs,
std::vector< Blob > &  outputs 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ inputNameToIndex()

virtual int cv::dnn::Layer::inputNameToIndex ( String  inputName)
virtual

Returns index of input blob into the input array.

Parameters
inputNamelabel of input blob

Each layer input and output can be labeled to easily identify them using "%<layer_name%>[.output_name]" notation. This method maps label of input blob to its index into input vector.

Reimplemented in cv::dnn::LSTMLayer.

§ outputNameToIndex()

virtual int cv::dnn::Layer::outputNameToIndex ( String  outputName)
virtual

Returns index of output blob in output array.

See also
inputNameToIndex()

Reimplemented in cv::dnn::LSTMLayer.

§ run()

void cv::dnn::Layer::run ( const std::vector< Blob > &  inputs,
std::vector< Blob > &  outputs 
)

Allocates layer and computes output.

§ setParamsFrom()

void cv::dnn::Layer::setParamsFrom ( const LayerParams params)

Initializes only name, type and blobs fields.

Member Data Documentation

§ blobs

std::vector<Blob> cv::dnn::Layer::blobs

List of learned parameters must be stored here to allow read them by using Net::getParam().

§ name

String cv::dnn::Layer::name

Name of the layer instance, can be used for logging or other internal purposes.

§ type

String cv::dnn::Layer::type

Type name which was used for creating layer by layer factory.


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