public class LSTM extends BaseRecurrentLayer<LSTM>
GravesLSTM class, for the version with peephole connections,
Serialized FormLayer.TrainingMode, Layer.Type| Modifier and Type | Field and Description |
|---|---|
protected FwdPassReturn |
cachedFwdPass |
protected LSTMHelper |
helper |
static String |
STATE_KEY_PREV_ACTIVATION |
static String |
STATE_KEY_PREV_MEMCELL |
helperCountFail, stateMap, tBpttStateMapgradient, gradientsFlattened, gradientViews, optimizer, params, paramsFlattened, score, solver, weightNoiseParamscacheMode, conf, dataType, dropoutApplied, epochCount, index, input, inputModificationAllowed, iterationCount, maskArray, maskState, preOutput, trainingListeners| Constructor and Description |
|---|
LSTM(NeuralNetConfiguration conf,
DataType dataType) |
| Modifier and Type | Method and Description |
|---|---|
INDArray |
activate(boolean training,
LayerWorkspaceMgr workspaceMgr)
Perform forward pass and return the activations array with the last set input
|
INDArray |
activate(INDArray input,
boolean training,
LayerWorkspaceMgr workspaceMgr)
Perform forward pass and return the activations array with the specified input
|
Pair<Gradient,INDArray> |
backpropGradient(INDArray epsilon,
LayerWorkspaceMgr workspaceMgr)
Calculate the gradient relative to the error in the next layer
|
Pair<INDArray,MaskState> |
feedForwardMaskArray(INDArray maskArray,
MaskState currentMaskState,
int minibatchSize)
Feed forward the input mask array, setting in the layer as appropriate.
|
LayerHelper |
getHelper() |
Gradient |
gradient()
Get the gradient.
|
boolean |
isPretrainLayer()
Returns true if the layer can be trained in an unsupervised/pretrain manner (AE, VAE, etc)
|
INDArray |
rnnActivateUsingStoredState(INDArray input,
boolean training,
boolean storeLastForTBPTT,
LayerWorkspaceMgr workspaceMgr)
Similar to rnnTimeStep, this method is used for activations using the state
stored in the stateMap as the initialization.
|
INDArray |
rnnTimeStep(INDArray input,
LayerWorkspaceMgr workspaceMgr)
Do one or more time steps using the previous time step state stored in stateMap.
Can be used to efficiently do forward pass one or n-steps at a time (instead of doing forward pass always from t=0) If stateMap is empty, default initialization (usually zeros) is used Implementations also update stateMap at the end of this method |
Pair<Gradient,INDArray> |
tbpttBackpropGradient(INDArray epsilon,
int tbpttBackwardLength,
LayerWorkspaceMgr workspaceMgr)
Truncated BPTT equivalent of Layer.backpropGradient().
|
Layer.Type |
type()
Returns the layer type
|
getDataFormat, permuteIfNWC, rnnClearPreviousState, rnnGetPreviousState, rnnGetTBPTTState, rnnSetPreviousState, rnnSetTBPTTStatecalcRegularizationScore, clear, clearNoiseWeightParams, clone, computeGradientAndScore, fit, fit, getGradientsViewArray, getOptimizer, getParam, getParamWithNoise, hasBias, hasLayerNorm, layerConf, numParams, params, paramTable, paramTable, preOutput, preOutputWithPreNorm, score, setBackpropGradientsViewArray, setParam, setParams, setParams, setParamsViewArray, setParamTable, setScoreWithZ, toString, update, updateaddListeners, allowInputModification, applyConstraints, applyDropOutIfNecessary, applyMask, assertInputSet, backpropDropOutIfPresent, batchSize, close, conf, getConfig, getEpochCount, getIndex, getInput, getInputMiniBatchSize, getListeners, getMaskArray, gradientAndScore, init, input, layerId, numParams, setCacheMode, setConf, setEpochCount, setIndex, setInput, setInputMiniBatchSize, setListeners, setListeners, setMaskArray, updaterDivideByMinibatchequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitallowInputModification, calcRegularizationScore, clearNoiseWeightParams, getEpochCount, getIndex, getInputMiniBatchSize, getIterationCount, getListeners, getMaskArray, setCacheMode, setEpochCount, setIndex, setInput, setInputMiniBatchSize, setIterationCount, setListeners, setListeners, setMaskArrayaddListeners, applyConstraints, batchSize, clear, close, computeGradientAndScore, conf, fit, fit, getGradientsViewArray, getOptimizer, getParam, gradientAndScore, init, input, numParams, numParams, params, paramTable, paramTable, score, setBackpropGradientsViewArray, setConf, setParam, setParams, setParamsViewArray, setParamTable, update, updategetConfig, getGradientsViewArray, numParams, params, paramTable, updaterDivideByMinibatchpublic static final String STATE_KEY_PREV_ACTIVATION
public static final String STATE_KEY_PREV_MEMCELL
protected LSTMHelper helper
protected FwdPassReturn cachedFwdPass
public LSTM(NeuralNetConfiguration conf, DataType dataType)
public Gradient gradient()
ModelModel.computeGradientAndScore(LayerWorkspaceMgr) } .public Pair<Gradient,INDArray> backpropGradient(INDArray epsilon, LayerWorkspaceMgr workspaceMgr)
LayerbackpropGradient in interface LayerbackpropGradient in class BaseLayer<LSTM>epsilon - w^(L+1)*delta^(L+1). Or, equiv: dC/da, i.e., (dC/dz)*(dz/da) = dC/da, where C
is cost function a=sigma(z) is activation.workspaceMgr - Workspace managerArrayType.ACTIVATION_GRAD workspace via the workspace managerpublic Pair<Gradient,INDArray> tbpttBackpropGradient(INDArray epsilon, int tbpttBackwardLength, LayerWorkspaceMgr workspaceMgr)
RecurrentLayerpublic INDArray activate(INDArray input, boolean training, LayerWorkspaceMgr workspaceMgr)
Layeractivate in interface Layeractivate in class AbstractLayer<LSTM>input - the input to usetraining - train or test modeworkspaceMgr - Workspace manager.ArrayType.ACTIVATIONS workspace via the workspace managerpublic INDArray activate(boolean training, LayerWorkspaceMgr workspaceMgr)
Layeractivate in interface Layeractivate in class BaseLayer<LSTM>training - training or test modeworkspaceMgr - Workspace managerArrayType.ACTIVATIONS workspace via the workspace managerpublic Layer.Type type()
Layertype in interface Layertype in class AbstractLayer<LSTM>public boolean isPretrainLayer()
Layerpublic Pair<INDArray,MaskState> feedForwardMaskArray(INDArray maskArray, MaskState currentMaskState, int minibatchSize)
LayerfeedForwardMaskArray in interface LayerfeedForwardMaskArray in class AbstractLayer<LSTM>maskArray - Mask array to setcurrentMaskState - Current state of the mask - see MaskStateminibatchSize - Current minibatch size. Needs to be known as it cannot always be inferred from the activations
array due to reshaping (such as a DenseLayer within a recurrent neural network)public INDArray rnnTimeStep(INDArray input, LayerWorkspaceMgr workspaceMgr)
RecurrentLayerinput - Input to this layerpublic INDArray rnnActivateUsingStoredState(INDArray input, boolean training, boolean storeLastForTBPTT, LayerWorkspaceMgr workspaceMgr)
RecurrentLayerinput - Layer inputtraining - if true: training. Otherwise: teststoreLastForTBPTT - If true: store the final state in tBpttStateMap for use in truncated BPTT trainingpublic LayerHelper getHelper()
getHelper in interface LayergetHelper in class AbstractLayer<LSTM>Copyright © 2020. All rights reserved.