@Namespace(value="cv::dnn") @Properties(inherit=opencv_dnn.class) public class GRULayer extends Layer
T
, N
, data_dims
] where T
is sequence length, N
is batch size, data_dims
is input size
- output would have shape [T
, N
, D
* hidden_size
] where D = 2
if layer is bidirectional otherwise D = 1
Depends on the following attributes:
- hidden_size - Number of neurons in the hidden layer
- direction - RNN could be bidirectional or forward
The final hidden state h_t
computes by the following formulas:
\begin{eqnarray*}
r_t = \sigma(W_{ir} x_t + b_{ir} + W_{hr} h_{(t-1)} + b_{hr}) \\
z_t = \sigma(W_{iz} x_t + b_{iz} + W_{hz} h_{(t-1)} + b_{hz}) \\
n_t = \tanh(W_{in} x_t + b_{in} + r_t \odot (W_{hn} h_{(t-1)}+ b_{hn})) \\
h_t = (1 - z_t) \odot n_t + z_t \odot h_{(t-1)} \\
\end{eqnarray*}
Where x_t
is current input, h_{(t-1)}
is previous or initial hidden state.
W_{x?}
, W_{h?}
and b_{?}
are learned weights represented as matrices:
W_{x?} \in R^{N_h \times N_x}
, W_{h?} \in R^{N_h \times N_h}
, b_? \in R^{N_h}
.
\odot
is per-element multiply operation.Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
GRULayer()
Default native constructor.
|
GRULayer(long size)
Native array allocator.
|
GRULayer(Pointer p)
Pointer cast constructor.
|
Modifier and Type | Method and Description |
---|---|
static GRULayer |
create(LayerParams params)
Creates instance of GRU layer
|
GRULayer |
getPointer(long i) |
GRULayer |
position(long position) |
applyHalideScheduler, asAlgorithm, asAlgorithm, blobs, blobs, finalize, finalize, finalize, finalize, finalize, forward_fallback, forward_fallback, forward_fallback, forward, forward, forward, forward, getFLOPS, getMemoryShapes, getScaleShift, getScaleZeropoint, getScaleZeropoint, getScaleZeropoint, inputNameToIndex, inputNameToIndex, name, name, outputNameToIndex, outputNameToIndex, preferableTarget, preferableTarget, run, setActivation, setParamsFrom, supportBackend, tryAttach, tryFuse, tryQuantize, type, type, unsetAttached, updateMemoryShapes
clear, empty, getDefaultName, read, save, save, write, write, write
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public GRULayer()
public GRULayer(long size)
Pointer.position(long)
.public GRULayer(Pointer p)
Pointer(Pointer)
.public GRULayer getPointer(long i)
getPointer
in class Layer
@opencv_core.Ptr public static GRULayer create(@Const @ByRef LayerParams params)
Copyright © 2024. All rights reserved.