@Namespace(value="cv::dnn") @Properties(inherit=opencv_dnn.class) public class RNNLayer extends Layer
Accepts two inputs x_t and h_{t-1} and compute two outputs o_t and h_t.
- input: should contain packed input x_t.
- output: should contain output o_t (and h_t if setProduceHiddenOutput() is set to true).
input[0] should have shape [T, N, data_dims] where T and N is number of timestamps and number of independent samples of x_t respectively.
output[0] will have shape [T, N, N_o], where N_o is number of rows in W_{xo} matrix.
If setProduceHiddenOutput() is set to true then \p output[1] will contain a Mat with shape [T, N, N_h], where N_h is number of rows in W_{hh} matrix.
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter| Constructor and Description |
|---|
RNNLayer(Pointer p)
Pointer cast constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static RNNLayer |
create(LayerParams params)
Creates instance of RNNLayer
|
void |
setProduceHiddenOutput() |
void |
setProduceHiddenOutput(boolean produce)
\brief If this flag is set to true then layer will produce
h_t as second output. |
void |
setWeights(Mat Wxh,
Mat bh,
Mat Whh,
Mat Who,
Mat bo)
Setups learned weights.
|
applyHalideScheduler, blobs, blobs, finalize, finalize, finalize, finalize, finalize, forward_fallback, forward_fallback, forward_fallback, forward, forward, forward, forward, getFLOPS, getMemoryShapes, getScaleShift, inputNameToIndex, inputNameToIndex, name, name, outputNameToIndex, outputNameToIndex, position, preferableTarget, preferableTarget, run, setActivation, setParamsFrom, supportBackend, tryAttach, tryFuse, type, type, unsetAttachedclear, empty, getDefaultName, read, save, save, write, write, writeaddress, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zeropublic RNNLayer(Pointer p)
Pointer.Pointer(Pointer).@opencv_core.Ptr public static RNNLayer create(@Const @ByRef LayerParams params)
public void setWeights(@Const @ByRef Mat Wxh, @Const @ByRef Mat bh, @Const @ByRef Mat Whh, @Const @ByRef Mat Who, @Const @ByRef Mat bo)
Recurrent-layer behavior on each step is defined by current input x_t , previous state h_t and learned weights as follows:
\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 - is W_{xh} matrixbh - is b_{h} vectorWhh - is W_{hh} matrixWho - is W_{xo} matrixbo - is b_{o} vectorpublic void setProduceHiddenOutput(@Cast(value="bool") boolean produce)
h_t as second output.
\details Shape of the second output is the same as first output.public void setProduceHiddenOutput()
Copyright © 2020. All rights reserved.