@Namespace(value="cv::dnn") public static class opencv_dnn.LSTMLayer extends opencv_dnn.Layer
| Constructor and Description |
|---|
LSTMLayer(org.bytedeco.javacpp.Pointer p)
Pointer cast constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static opencv_dnn.LSTMLayer |
create(opencv_dnn.LayerParams params)
Creates instance of LSTM layer
|
int |
inputNameToIndex(org.bytedeco.javacpp.BytePointer inputName)
\brief Returns index of input blob into the input array.
|
int |
inputNameToIndex(String inputName) |
int |
outputNameToIndex(org.bytedeco.javacpp.BytePointer outputName)
\brief Returns index of output blob in output array.
|
int |
outputNameToIndex(String outputName) |
void |
setOutShape() |
void |
setOutShape(org.bytedeco.javacpp.IntPointer outTailShape)
\brief Specifies shape of output blob which will be [[
T], N] + \p outTailShape. |
void |
setProduceCellOutput()
Deprecated.
|
void |
setProduceCellOutput(boolean produce)
Deprecated.
Use flag
use_timestamp_dim in LayerParams.
\brief If this flag is set to true then layer will produce \f$ c_t \f$ as second output.
\details Shape of the second output is the same as first output. |
void |
setUseTimstampsDim()
Deprecated.
|
void |
setUseTimstampsDim(boolean use)
Deprecated.
Use flag
produce_cell_output in LayerParams.
\brief Specifies either interpret first dimension of input blob as timestamp dimenion either as sample.
If flag is set to true then shape of input blob will be interpreted as [T, N, [data dims]] where T specifies number of timestamps, N is number of independent streams.
In this case each forward() call will iterate through T timestamps and update layer's state T times.
If flag is set to false then shape of input blob will be interpreted as [N, [data dims]].
In this case each forward() call will make one iteration and produce one timestamp with shape [N, [out dims]]. |
void |
setWeights(opencv_core.Mat Wh,
opencv_core.Mat Wx,
opencv_core.Mat b)
Deprecated.
Use LayerParams::blobs instead.
\brief Set trained weights for LSTM layer.
LSTM behavior on each step is defined by current input, previous output, previous cell state and learned weights. Let \f$x_t\f$ be current input, \f$h_t\f$ be current output, \f$c_t\f$ be current state. Than current output and current cell state is computed as follows: \f{eqnarray*}{ h_t &= o_t \odot tanh(c_t), \\ c_t &= f_t \odot c_{t-1} + i_t \odot g_t, \\ \f} where \f$\odot\f$ is per-element multiply operation and \f$i_t, f_t, o_t, g_t\f$ is internal gates that are computed using learned wights. Gates are computed as follows: \f{eqnarray*}{ i_t &= sigmoid&(W_{xi} x_t + W_{hi} h_{t-1} + b_i), \\ f_t &= sigmoid&(W_{xf} x_t + W_{hf} h_{t-1} + b_f), \\ o_t &= sigmoid&(W_{xo} x_t + W_{ho} h_{t-1} + b_o), \\ g_t &= tanh &(W_{xg} x_t + W_{hg} h_{t-1} + b_g), \\ \f} where \f$W_{x?}\f$, \f$W_{h?}\f$ and \f$b_{?}\f$ are learned weights represented as matrices: \f$W_{x?} \in R^{N_h \times N_x}\f$, \f$W_{h?} \in R^{N_h \times N_h}\f$, \f$b_? \in R^{N_h}\f$. For simplicity and performance purposes we use \f$ W_x = [W_{xi}; W_{xf}; W_{xo}, W_{xg}] \f$ (i.e. \f$W_x\f$ is vertical concatenation of \f$ W_{x?} \f$), \f$ W_x \in R^{4N_h \times N_x} \f$. The same for \f$ W_h = [W_{hi}; W_{hf}; W_{ho}, W_{hg}], W_h \in R^{4N_h \times N_h} \f$ and for \f$ b = [b_i; b_f, b_o, b_g]\f$, \f$b \in R^{4N_h} \f$. |
applyHalideScheduler, blobs, blobs, finalize, finalize, finalize, forward_fallback, forward_fallback, forward_fallback, forward, forward, forward, forward, getFLOPS, getMemoryShapes, getScaleShift, name, name, preferableTarget, preferableTarget, run, setActivation, setParamsFrom, supportBackend, tryAttach, tryFuse, type, type, unsetAttachedclear, empty, getDefaultName, position, read, save, save, write, write, writeaddress, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zeropublic LSTMLayer(org.bytedeco.javacpp.Pointer p)
Pointer.Pointer(Pointer).@opencv_core.Ptr public static opencv_dnn.LSTMLayer create(@Const @ByRef opencv_dnn.LayerParams params)
@Deprecated public void setWeights(@Const @ByRef opencv_core.Mat Wh, @Const @ByRef opencv_core.Mat Wx, @Const @ByRef opencv_core.Mat b)
LSTM behavior on each step is defined by current input, previous output, previous cell state and learned weights.
Let \f$x_t\f$ be current input, \f$h_t\f$ be current output, \f$c_t\f$ be current state. Than current output and current cell state is computed as follows: \f{eqnarray*}{ h_t &= o_t \odot tanh(c_t), \\ c_t &= f_t \odot c_{t-1} + i_t \odot g_t, \\ \f} where \f$\odot\f$ is per-element multiply operation and \f$i_t, f_t, o_t, g_t\f$ is internal gates that are computed using learned wights.
Gates are computed as follows: \f{eqnarray*}{ i_t &= sigmoid&(W_{xi} x_t + W_{hi} h_{t-1} + b_i), \\ f_t &= sigmoid&(W_{xf} x_t + W_{hf} h_{t-1} + b_f), \\ o_t &= sigmoid&(W_{xo} x_t + W_{ho} h_{t-1} + b_o), \\ g_t &= tanh &(W_{xg} x_t + W_{hg} h_{t-1} + b_g), \\ \f} where \f$W_{x?}\f$, \f$W_{h?}\f$ and \f$b_{?}\f$ are learned weights represented as matrices: \f$W_{x?} \in R^{N_h \times N_x}\f$, \f$W_{h?} \in R^{N_h \times N_h}\f$, \f$b_? \in R^{N_h}\f$.
For simplicity and performance purposes we use \f$ W_x = [W_{xi}; W_{xf}; W_{xo}, W_{xg}] \f$ (i.e. \f$W_x\f$ is vertical concatenation of \f$ W_{x?} \f$), \f$ W_x \in R^{4N_h \times N_x} \f$. The same for \f$ W_h = [W_{hi}; W_{hf}; W_{ho}, W_{hg}], W_h \in R^{4N_h \times N_h} \f$ and for \f$ b = [b_i; b_f, b_o, b_g]\f$, \f$b \in R^{4N_h} \f$.
Wh - is matrix defining how previous output is transformed to internal gates (i.e. according to above mentioned notation is \f$ W_h \f$)Wx - is matrix defining how current input is transformed to internal gates (i.e. according to above mentioned notation is \f$ W_x \f$)b - is bias vector (i.e. according to above mentioned notation is \f$ b \f$)public void setOutShape(@Const @StdVector @ByRef(nullValue="cv::dnn::MatShape()")
org.bytedeco.javacpp.IntPointer outTailShape)
T], N] + \p outTailShape.
\details If this parameter is empty or unset then \p outTailShape = [Wh.size(0)] will be used,
where Wh is parameter from setWeights().public void setOutShape()
@Deprecated public void setUseTimstampsDim(@Cast(value="bool") boolean use)
produce_cell_output in LayerParams.
\brief Specifies either interpret first dimension of input blob as timestamp dimenion either as sample.
If flag is set to true then shape of input blob will be interpreted as [T, N, [data dims]] where T specifies number of timestamps, N is number of independent streams.
In this case each forward() call will iterate through T timestamps and update layer's state T times.
If flag is set to false then shape of input blob will be interpreted as [N, [data dims]].
In this case each forward() call will make one iteration and produce one timestamp with shape [N, [out dims]].@Deprecated public void setUseTimstampsDim()
@Deprecated public void setProduceCellOutput(@Cast(value="bool") boolean produce)
use_timestamp_dim in LayerParams.
\brief If this flag is set to true then layer will produce \f$ c_t \f$ as second output.
\details Shape of the second output is the same as first output.@Deprecated public void setProduceCellOutput()
public int inputNameToIndex(@opencv_core.Str org.bytedeco.javacpp.BytePointer inputName)
opencv_dnn.LayerinputNameToIndex in class opencv_dnn.LayerinputName - label of input blob
Each layer input and output can be labeled to easily identify them using "%public int inputNameToIndex(@opencv_core.Str String inputName)
inputNameToIndex in class opencv_dnn.Layerpublic int outputNameToIndex(@opencv_core.Str org.bytedeco.javacpp.BytePointer outputName)
opencv_dnn.LayeroutputNameToIndex in class opencv_dnn.LayerinputNameToIndex()public int outputNameToIndex(@opencv_core.Str String outputName)
outputNameToIndex in class opencv_dnn.LayerCopyright © 2018. All rights reserved.