Package ai.djl.nn.recurrent
Class RecurrentBlock.BaseBuilder<T extends RecurrentBlock.BaseBuilder>
- java.lang.Object
-
- ai.djl.nn.recurrent.RecurrentBlock.BaseBuilder<T>
-
- Direct Known Subclasses:
GRU.Builder
,LSTM.Builder
,RNN.Builder
- Enclosing class:
- RecurrentBlock
public abstract static class RecurrentBlock.BaseBuilder<T extends RecurrentBlock.BaseBuilder> extends java.lang.Object
The Builder to construct aRecurrentBlock
type ofBlock
.
-
-
Field Summary
Fields Modifier and Type Field Description protected RNN.Activation
activation
protected boolean
batchFirst
protected boolean
bidirectional
protected float
dropRate
protected boolean
hasBiases
protected int
numLayers
protected boolean
returnState
protected long
stateSize
-
Constructor Summary
Constructors Constructor Description BaseBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
optBatchFirst(boolean batchFirst)
Sets the optional batchFirst flag that indicates whether the input is batch major or not.T
optBidirectional(boolean useBidirectional)
Sets the optional parameter that indicates whether to use bidirectional recurrent layers.T
optDropRate(float dropRate)
Sets the drop rate of the dropout on the outputs of each RNN layer, except the last layer.T
optHasBiases(boolean hasBiases)
Sets the optional biases flag that indicates whether to use biases or not.T
optReturnState(boolean returnState)
Sets the optional flag that indicates whether to return state or not.protected abstract T
self()
T
setNumLayers(int numLayers)
Sets the Required number of stacked layers.T
setStateSize(int stateSize)
Sets the Required size of the state for each layer.
-
-
-
Field Detail
-
dropRate
protected float dropRate
-
stateSize
protected long stateSize
-
numLayers
protected int numLayers
-
batchFirst
protected boolean batchFirst
-
hasBiases
protected boolean hasBiases
-
bidirectional
protected boolean bidirectional
-
returnState
protected boolean returnState
-
activation
protected RNN.Activation activation
-
-
Method Detail
-
optDropRate
public T optDropRate(float dropRate)
Sets the drop rate of the dropout on the outputs of each RNN layer, except the last layer.- Parameters:
dropRate
- the drop rate of the dropout- Returns:
- this Builder
-
setStateSize
public T setStateSize(int stateSize)
Sets the Required size of the state for each layer.- Parameters:
stateSize
- the size of the state for each layer- Returns:
- this Builder
-
setNumLayers
public T setNumLayers(int numLayers)
Sets the Required number of stacked layers.- Parameters:
numLayers
- the number of stacked layers- Returns:
- this Builder
-
optBidirectional
public T optBidirectional(boolean useBidirectional)
Sets the optional parameter that indicates whether to use bidirectional recurrent layers.- Parameters:
useBidirectional
- whether to use bidirectional recurrent layers- Returns:
- this Builder
-
optBatchFirst
public T optBatchFirst(boolean batchFirst)
Sets the optional batchFirst flag that indicates whether the input is batch major or not. The default value is true.- Parameters:
batchFirst
- whether the input is batch major or not- Returns:
- this Builder
-
optHasBiases
public T optHasBiases(boolean hasBiases)
Sets the optional biases flag that indicates whether to use biases or not.- Parameters:
hasBiases
- whether to use biases or not- Returns:
- this Builder
-
optReturnState
public T optReturnState(boolean returnState)
Sets the optional flag that indicates whether to return state or not. This is typically useful when you use RecurrentBlock in Sequential block. The default value is false.- Parameters:
returnState
- whether to return state or not- Returns:
- this Builder
-
self
protected abstract T self()
-
-