OpenCV453
公開メンバ関数 | 公開変数類 | 全メンバ一覧
cv::dnn::Layer クラス

This interface class allows to build new Layers - are building blocks of networks. [詳解]

#include <dnn.hpp>

cv::Algorithmを継承しています。

cv::dnn::AccumLayer, cv::dnn::ActivationLayer, cv::dnn::BaseConvolutionLayer, cv::dnn::BlankLayer, cv::dnn::ConcatLayer, cv::dnn::ConstLayer, cv::dnn::CorrelationLayer, cv::dnn::CropAndResizeLayer, cv::dnn::CropLayer, cv::dnn::DataAugmentationLayer, cv::dnn::DetectionOutputLayer, cv::dnn::EltwiseLayer, cv::dnn::FlattenLayer, cv::dnn::FlowWarpLayer, cv::dnn::InnerProductLayer, cv::dnn::InterpLayer, cv::dnn::LRNLayer, cv::dnn::LSTMLayer, cv::dnn::MVNLayer, cv::dnn::MaxUnpoolLayer, cv::dnn::NormalizeBBoxLayer, cv::dnn::PaddingLayer, cv::dnn::PermuteLayer, cv::dnn::PoolingLayer, cv::dnn::PriorBoxLayer, cv::dnn::ProposalLayer, cv::dnn::RNNLayer, cv::dnn::RegionLayer, cv::dnn::ReorgLayer, cv::dnn::ReshapeLayer, cv::dnn::ResizeLayer, cv::dnn::ScaleLayer, cv::dnn::ShiftLayer, cv::dnn::ShuffleChannelLayer, cv::dnn::SliceLayer, cv::dnn::SoftmaxLayer, cv::dnn::SplitLayer (計37項目)に継承されています。

公開メンバ関数

virtual CV_DEPRECATED_EXTERNAL void finalize (const std::vector< Mat * > &input, std::vector< Mat > &output)
 Computes and sets internal parameters according to inputs, outputs and blobs. [詳解]
 
virtual CV_WRAP void finalize (InputArrayOfArrays inputs, OutputArrayOfArrays outputs)
 Computes and sets internal parameters according to inputs, outputs and blobs. [詳解]
 
virtual CV_DEPRECATED_EXTERNAL void forward (std::vector< Mat * > &input, std::vector< Mat > &output, std::vector< Mat > &internals)
 Given the input blobs, computes the output blobs. [詳解]
 
virtual void forward (InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals)
 Given the input blobs, computes the output blobs. [詳解]
 
void forward_fallback (InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals)
 Given the input blobs, computes the output blobs. [詳解]
 
CV_DEPRECATED_EXTERNAL void finalize (const std::vector< Mat > &inputs, CV_OUT std::vector< Mat > &outputs)
 これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。 [詳解]
 
CV_DEPRECATED std::vector< Matfinalize (const std::vector< Mat > &inputs)
 これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。 [詳解]
 
CV_DEPRECATED CV_WRAP void run (const std::vector< Mat > &inputs, CV_OUT std::vector< Mat > &outputs, CV_IN_OUT std::vector< Mat > &internals)
 Allocates layer and computes output. [詳解]
 
virtual int inputNameToIndex (String inputName)
 Returns index of input blob into the input array. [詳解]
 
virtual CV_WRAP int outputNameToIndex (const String &outputName)
 Returns index of output blob in output array. [詳解]
 
virtual bool supportBackend (int backendId)
 Ask layer if it support specific backend for doing computations. [詳解]
 
virtual Ptr< BackendNodeinitHalide (const std::vector< Ptr< BackendWrapper > > &inputs)
 Returns Halide backend node. [詳解]
 
virtual Ptr< BackendNodeinitInfEngine (const std::vector< Ptr< BackendWrapper > > &inputs)
 
virtual Ptr< BackendNodeinitNgraph (const std::vector< Ptr< BackendWrapper > > &inputs, const std::vector< Ptr< BackendNode > > &nodes)
 
virtual Ptr< BackendNodeinitVkCom (const std::vector< Ptr< BackendWrapper > > &inputs)
 
virtual Ptr< BackendNodeinitCUDA (void *context, const std::vector< Ptr< BackendWrapper > > &inputs, const std::vector< Ptr< BackendWrapper > > &outputs)
 Returns a CUDA backend node [詳解]
 
virtual void applyHalideScheduler (Ptr< BackendNode > &node, const std::vector< Mat * > &inputs, const std::vector< Mat > &outputs, int targetId) const
 Automatic Halide scheduling based on layer hyper-parameters. [詳解]
 
virtual Ptr< BackendNodetryAttach (const Ptr< BackendNode > &node)
 Implement layers fusing. [詳解]
 
virtual bool setActivation (const Ptr< ActivationLayer > &layer)
 Tries to attach to the layer the subsequent activation layer, i.e. do the layer fusion in a partial case. [詳解]
 
virtual bool tryFuse (Ptr< Layer > &top)
 Try to fuse current layer with a next one [詳解]
 
virtual void getScaleShift (Mat &scale, Mat &shift) const
 Returns parameters of layers with channel-wise multiplication and addition. [詳解]
 
virtual void unsetAttached ()
 "Deattaches" all the layers, attached to particular layer.
 
virtual bool getMemoryShapes (const std::vector< MatShape > &inputs, const int requiredOutputs, std::vector< MatShape > &outputs, std::vector< MatShape > &internals) const
 
virtual int64 getFLOPS (const std::vector< MatShape > &inputs, const std::vector< MatShape > &outputs) const
 
virtual bool updateMemoryShapes (const std::vector< MatShape > &inputs)
 
 Layer (const LayerParams &params)
 Initializes only name, type and blobs fields.
 
void setParamsFrom (const LayerParams &params)
 Initializes only name, type and blobs fields.
 
- 基底クラス cv::Algorithm に属する継承公開メンバ関数
virtual CV_WRAP void clear ()
 Clears the algorithm state [詳解]
 
virtual void write (FileStorage &fs) const
 Stores algorithm parameters in a file storage [詳解]
 
CV_WRAP void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 simplified API for language bindings これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。
 
virtual CV_WRAP void read (const FileNode &fn)
 Reads algorithm parameters from a file storage [詳解]
 
virtual CV_WRAP bool empty () const
 Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read [詳解]
 
virtual CV_WRAP void save (const String &filename) const
 
virtual CV_WRAP String getDefaultName () const
 

公開変数類

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

その他の継承メンバ

- 基底クラス cv::Algorithm に属する継承静的公開メンバ関数
template<typename _Tp >
static Ptr< _Tp > read (const FileNode &fn)
 Reads algorithm from the file node [詳解]
 
template<typename _Tp >
static Ptr< _Tp > load (const String &filename, const String &objname=String())
 Loads algorithm from the file [詳解]
 
template<typename _Tp >
static Ptr< _Tp > loadFromString (const String &strModel, const String &objname=String())
 Loads algorithm from a String [詳解]
 
- 基底クラス cv::Algorithm に属する継承限定公開メンバ関数
void writeFormat (FileStorage &fs) const
 

詳解

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.

関数詳解

◆ applyHalideScheduler()

virtual void cv::dnn::Layer::applyHalideScheduler ( Ptr< BackendNode > &  node,
const std::vector< Mat * > &  inputs,
const std::vector< Mat > &  outputs,
int  targetId 
) const
virtual

Automatic Halide scheduling based on layer hyper-parameters.

引数
[in]nodeBackend node with Halide functions.
[in]inputsBlobs that will be used in forward invocations.
[in]outputsBlobs that will be used in forward invocations.
[in]targetIdTarget identifier
参照
BackendNode, Target

Layer don't use own Halide::Func members because we can have applied layers fusing. In this way the fused function should be scheduled.

◆ finalize() [1/4]

virtual CV_DEPRECATED_EXTERNAL void cv::dnn::Layer::finalize ( const std::vector< Mat * > &  input,
std::vector< Mat > &  output 
)
virtual

Computes and sets internal parameters according to inputs, outputs and blobs.

非推奨:
Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead
引数
[in]inputvector of already allocated input blobs
[out]outputvector of already allocated output blobs

If this method is called after network has allocated all memory for input and output blobs and before inferencing.

◆ finalize() [2/4]

CV_DEPRECATED std::vector< Mat > cv::dnn::Layer::finalize ( const std::vector< Mat > &  inputs)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

非推奨:
Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead

◆ finalize() [3/4]

CV_DEPRECATED_EXTERNAL void cv::dnn::Layer::finalize ( const std::vector< Mat > &  inputs,
CV_OUT std::vector< Mat > &  outputs 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

非推奨:
Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead

◆ finalize() [4/4]

virtual CV_WRAP void cv::dnn::Layer::finalize ( InputArrayOfArrays  inputs,
OutputArrayOfArrays  outputs 
)
virtual

Computes and sets internal parameters according to inputs, outputs and blobs.

引数
[in]inputsvector of already allocated input blobs
[out]outputsvector of already allocated output blobs

If this method is called after network has allocated all memory for input and output blobs and before inferencing.

◆ forward() [1/2]

virtual void cv::dnn::Layer::forward ( InputArrayOfArrays  inputs,
OutputArrayOfArrays  outputs,
OutputArrayOfArrays  internals 
)
virtual

Given the input blobs, computes the output blobs.

引数
[in]inputsthe input blobs.
[out]outputsallocated output blobs, which will store results of the computation.
[out]internalsallocated internal blobs

◆ forward() [2/2]

virtual CV_DEPRECATED_EXTERNAL void cv::dnn::Layer::forward ( std::vector< Mat * > &  input,
std::vector< Mat > &  output,
std::vector< Mat > &  internals 
)
virtual

Given the input blobs, computes the output blobs.

非推奨:
Use Layer::forward(InputArrayOfArrays, OutputArrayOfArrays, OutputArrayOfArrays) instead
引数
[in]inputthe input blobs.
[out]outputallocated output blobs, which will store results of the computation.
[out]internalsallocated internal blobs

◆ forward_fallback()

void cv::dnn::Layer::forward_fallback ( InputArrayOfArrays  inputs,
OutputArrayOfArrays  outputs,
OutputArrayOfArrays  internals 
)

Given the input blobs, computes the output blobs.

引数
[in]inputsthe input blobs.
[out]outputsallocated output blobs, which will store results of the computation.
[out]internalsallocated internal blobs

◆ getScaleShift()

virtual void cv::dnn::Layer::getScaleShift ( Mat scale,
Mat shift 
) const
virtual

Returns parameters of layers with channel-wise multiplication and addition.

引数
[out]scaleChannel-wise multipliers. Total number of values should be equal to number of channels.
[out]shiftChannel-wise offsets. Total number of values should be equal to number of channels.

Some layers can fuse their transformations with further layers. In example, convolution + batch normalization. This way base layer use weights from layer after it. Fused layer is skipped. By default, scale and shift are empty that means layer has no element-wise multiplications or additions.

◆ initCUDA()

virtual Ptr< BackendNode > cv::dnn::Layer::initCUDA ( void *  context,
const std::vector< Ptr< BackendWrapper > > &  inputs,
const std::vector< Ptr< BackendWrapper > > &  outputs 
)
virtual

Returns a CUDA backend node

引数
contextvoid pointer to CSLContext object
inputslayer inputs
outputslayer outputs

◆ initHalide()

virtual Ptr< BackendNode > cv::dnn::Layer::initHalide ( const std::vector< Ptr< BackendWrapper > > &  inputs)
virtual

Returns Halide backend node.

引数
[in]inputsInput Halide buffers.
参照
BackendNode, BackendWrapper

Input buffers should be exactly the same that will be used in forward invocations. Despite we can use Halide::ImageParam based on input shape only, it helps prevent some memory management issues (if something wrong, Halide tests will be failed).

◆ inputNameToIndex()

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

Returns index of input blob into the input array.

引数
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.

cv::dnn::LSTMLayerで再実装されています。

◆ outputNameToIndex()

virtual CV_WRAP int cv::dnn::Layer::outputNameToIndex ( const String &  outputName)
virtual

Returns index of output blob in output array.

参照
inputNameToIndex()

cv::dnn::LSTMLayerで再実装されています。

◆ run()

CV_DEPRECATED CV_WRAP void cv::dnn::Layer::run ( const std::vector< Mat > &  inputs,
CV_OUT std::vector< Mat > &  outputs,
CV_IN_OUT std::vector< Mat > &  internals 
)

Allocates layer and computes output.

非推奨:
This method will be removed in the future release.

◆ setActivation()

virtual bool cv::dnn::Layer::setActivation ( const Ptr< ActivationLayer > &  layer)
virtual

Tries to attach to the layer the subsequent activation layer, i.e. do the layer fusion in a partial case.

引数
[in]layerThe subsequent activation layer.

Returns true if the activation layer has been attached successfully.

◆ supportBackend()

virtual bool cv::dnn::Layer::supportBackend ( int  backendId)
virtual

Ask layer if it support specific backend for doing computations.

引数
[in]backendIdcomputation backend identifier.
参照
Backend

◆ tryAttach()

virtual Ptr< BackendNode > cv::dnn::Layer::tryAttach ( const Ptr< BackendNode > &  node)
virtual

Implement layers fusing.

引数
[in]nodeBackend node of bottom layer.
参照
BackendNode

Actual for graph-based backends. If layer attached successfully, returns non-empty cv::Ptr to node of the same backend. Fuse only over the last function.

◆ tryFuse()

virtual bool cv::dnn::Layer::tryFuse ( Ptr< Layer > &  top)
virtual

Try to fuse current layer with a next one

引数
[in]topNext layer to be fused.
戻り値
True if fusion was performed.

このクラス詳解は次のファイルから抽出されました: