![]() |
OpenCV 5.0.0
Open Source Computer Vision
|
古典的なリカレントレイヤ。 続き...
#include <opencv2/dnn/all_layers.hpp>
公開メンバ関数 | |
| virtual void | setProduceHiddenOutput (bool produce=false)=0 |
| このフラグをtrueに設定すると、レイヤは \( h_t \) を2番目の出力として生成する。 | |
| virtual void | setWeights (const Mat &Wxh, const Mat &bh, const Mat &Whh, const Mat &Who, const Mat &bo)=0 |
Public Member Functions inherited from cv::dnn::Layer | |
| Layer () | |
| Layer (const LayerParams ¶ms) | |
| name、type、blobs フィールドのみを初期化する。 | |
| virtual | ~Layer () |
| virtual bool | alwaysSupportInplace () const |
| virtual std::ostream & | dump (std::ostream &strm, int indent, bool comma) const |
| virtual std::ostream & | dumpAttrs (std::ostream &strm, int indent) const |
| virtual bool | dynamicOutputShapes () const |
| virtual void | finalize (const std::vector< Mat * > &input, std::vector< Mat > &output) |
| 入力・出力・blobに応じて内部パラメータを計算し設定する。 | |
| std::vector< Mat > | finalize (const std::vector< Mat > &inputs) |
| これは利便性のために提供されているオーバーロードされたメンバ関数である。上記の関数とは受け取る引数のみが異なる。 | |
| void | finalize (const std::vector< Mat > &inputs, std::vector< Mat > &outputs) |
| これは利便性のために提供されているオーバーロードされたメンバ関数である。上記の関数とは受け取る引数のみが異なる。 | |
| virtual void | finalize (InputArrayOfArrays inputs, OutputArrayOfArrays outputs) |
| 入力・出力・blobに応じて内部パラメータを計算し設定する。 | |
| virtual void | forward (InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals) |
input blobを与えて出力 blobs を計算する。 | |
| virtual void | forward (std::vector< Mat * > &input, std::vector< Mat > &output, std::vector< Mat > &internals) |
input blobを与えて出力 blobs を計算する。 | |
| void | forward_fallback (InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals) |
input blobを与えて出力 blobs を計算する。 | |
| virtual int64 | getFLOPS (const std::vector< MatShape > &inputs, const std::vector< MatShape > &outputs) const |
| virtual int | getLayouts (const std::vector< DataLayout > &actualInputs, std::vector< DataLayout > &desiredInputs, const int requiredOutputs, std::vector< DataLayout > &outputs) const |
| virtual bool | getMemoryShapes (const std::vector< MatShape > &inputs, const int requiredOutputs, std::vector< MatShape > &outputs, std::vector< MatShape > &internals) const |
| virtual void | getScaleShift (Mat &scale, Mat &shift) const |
| チャンネルごとの乗算と加算を行うレイヤーのパラメータを返す。 | |
| virtual void | getScaleZeropoint (float &scale, int &zeropoint) const |
| レイヤーのスケールとゼロポイントを返す。 | |
| virtual void | getTypes (const std::vector< MatType > &inputs, const int requiredOutputs, const int requiredInternals, std::vector< MatType > &outputs, std::vector< MatType > &internals) const |
| virtual Ptr< BackendNode > | initCann (const std::vector< Ptr< BackendWrapper > > &inputs, const std::vector< Ptr< BackendWrapper > > &outputs, const std::vector< Ptr< BackendNode > > &nodes) |
| CANNバックエンドノードを返す。 | |
| virtual Ptr< BackendNode > | initCUDA (void *context, const std::vector< Ptr< BackendWrapper > > &inputs, const std::vector< Ptr< BackendWrapper > > &outputs) |
| CUDAバックエンドノードを返す。 | |
| virtual Ptr< BackendNode > | initNgraph (const std::vector< Ptr< BackendWrapper > > &inputs, const std::vector< Ptr< BackendNode > > &nodes) |
| virtual Ptr< BackendNode > | initTimVX (void *timVxInfo, const std::vector< Ptr< BackendWrapper > > &inputsWrapper, const std::vector< Ptr< BackendWrapper > > &outputsWrapper, bool isLast) |
| TimVXバックエンドノードを返す。 | |
| virtual Ptr< BackendNode > | initVkCom (const std::vector< Ptr< BackendWrapper > > &inputs, std::vector< Ptr< BackendWrapper > > &outputs) |
| virtual Ptr< BackendNode > | initWebnn (const std::vector< Ptr< BackendWrapper > > &inputs, const std::vector< Ptr< BackendNode > > &nodes) |
| virtual int | inputNameToIndex (String inputName) |
| 入力配列における入力blobのインデックスを返す。 | |
| virtual bool | isDataShuffling () const |
| virtual int | outputNameToIndex (const String &outputName) |
| 出力配列における出力blobのインデックスを返す。 | |
| void | run (const std::vector< Mat > &inputs, std::vector< Mat > &outputs, std::vector< Mat > &internals) |
| レイヤーを確保し出力を計算する。 | |
| virtual bool | setActivation (const Ptr< ActivationLayer > &layer) |
| 後続の活性化レイヤーをこのレイヤーに結合しようとする。すなわち、部分的なケースでレイヤー融合を行う。 | |
| void | setParamsFrom (const LayerParams ¶ms) |
| name、type、blobs フィールドのみを初期化する。 | |
| virtual std::vector< Ptr< Graph > > * | subgraphs () const |
| virtual bool | supportBackend (int backendId) |
| 計算に特定のバックエンドをレイヤーがサポートしているか問い合わせる。 | |
| virtual bool | tryFuse (Ptr< Layer > &top) |
| 現在のレイヤーを次のレイヤーと融合しようとする。 | |
| virtual void | unsetAttached () |
| 特定のレイヤーに結合されているすべてのレイヤーを「切り離す」。 | |
| virtual bool | updateMemoryShapes (const std::vector< MatShape > &inputs) |
Public Member Functions inherited from cv::Algorithm | |
| Algorithm () | |
| virtual | ~Algorithm () |
| virtual void | clear () |
| アルゴリズムの状態をクリアする。 | |
| virtual bool | empty () const |
| Algorithm が空の場合(たとえば開始直後や読み込みに失敗した後)に true を返す。 | |
| virtual String | getDefaultName () const |
| virtual void | read (const FileNode &fn) |
| ファイルストレージからアルゴリズムの引数を読み込む。 | |
| virtual void | save (const String &filename) const |
| virtual void | write (FileStorage &fs) const |
| アルゴリズムの引数をファイルストレージに保存する。 | |
| void | write (FileStorage &fs, const String &name) const |
静的公開メンバ関数 | |
| static Ptr< RNNLayer > | create (const LayerParams ¶ms) |
Static Public Member Functions inherited from cv::Algorithm | |
| template<typename _Tp > | |
| static Ptr< _Tp > | load (const String &filename, const String &objname=String()) |
| ファイルからアルゴリズムを読み込む。 | |
| template<typename _Tp > | |
| static Ptr< _Tp > | loadFromString (const String &strModel, const String &objname=String()) |
| 文字列からアルゴリズムを読み込む。 | |
| template<typename _Tp > | |
| static Ptr< _Tp > | read (const FileNode &fn) |
| ファイルノードからアルゴリズムを読み込む。 | |
Additional Inherited Members | |
Public Attributes inherited from cv::dnn::Layer | |
| std::vector< Mat > | blobs |
| 学習済みの引数のリストは、Net::getParam() を使って読み出せるよう、ここに格納しなければならない。 | |
| std::vector< Arg > | inputs |
| String | name |
| レイヤーインスタンスの名前。ロギングやその他の内部目的に使用できる。 | |
| void * | netimpl |
| std::vector< Arg > | outputs |
| int | preferableTarget |
| レイヤーの順伝播において優先するターゲット | |
| String | type |
| レイヤーファクトリでレイヤーを作成する際に使用された型名。 | |
Protected Member Functions inherited from cv::Algorithm | |
| void | writeFormat (FileStorage &fs) const |
古典的なリカレントレイヤ。
2つの入力 \(x_t\) と \(h_{t-1}\) を受け取り、2つの出力 \(o_t\) と \(h_t\) を計算する。
input[0] は [T, N, data_dims] という形状を持つべきである。ここで T と N はそれぞれタイムスタンプ数と \(x_t\) の独立したサンプル数である。
output[0] は [T, N, \(N_o\)] という形状を持つ。ここで \(N_o\) は \( W_{xo} \) 行列の行数である。
setProduceHiddenOutput() が true に設定されている場合、output[1] は形状 [T, N, \(N_h\)] の Mat を含む。ここで \(N_h\) は \( W_{hh} \) 行列の行数である。
|
static |
RNNLayer のインスタンスを生成する
|
pure virtual |
このフラグをtrueに設定すると、レイヤは \( h_t \) を2番目の出力として生成する。
2番目の出力の形状は1番目の出力と同じである。
|
pure virtual |
学習済みの重みを設定する。
各ステップにおけるリカレントレイヤの挙動は、現在の入力 \( x_t \)、前の状態 \( h_t \)、および学習済みの重みによって、次のように定義される:
\begin{eqnarray*} h_t &= tanh&(W_{hh} h_{t-1} + W_{xh} x_t + b_h), \\ o_t &= tanh&(W_{ho} h_t + b_o), \end{eqnarray*}
| Wxh | は \( W_{xh} \) 行列である |
| bh | は \( b_{h} \) ベクトルである |
| Whh | は \( W_{hh} \) 行列である |
| Who | は \( W_{xo} \) 行列である |
| bo | は \( b_{o} \) ベクトルである |