public interface Layer extends Serializable, Cloneable, Model, Trainable
Modifier and Type | Interface and Description |
---|---|
static class |
Layer.TrainingMode |
static class |
Layer.Type |
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 mgr)
Perform forward pass and return the activations array with the specified input
|
void |
allowInputModification(boolean allow)
A performance optimization: mark whether the layer is allowed to modify its input array in-place.
|
Pair<Gradient,INDArray> |
backpropGradient(INDArray epsilon,
LayerWorkspaceMgr workspaceMgr)
Calculate the gradient relative to the error in the next layer
|
double |
calcRegularizationScore(boolean backpropOnlyParams)
Calculate the regularization component of the score, for the parameters in this layer
For example, the L1, L2 and/or weight decay components of the loss function |
void |
clearNoiseWeightParams() |
Pair<INDArray,MaskState> |
feedForwardMaskArray(INDArray maskArray,
MaskState currentMaskState,
int minibatchSize)
Feed forward the input mask array, setting in the layer as appropriate.
|
int |
getEpochCount() |
LayerHelper |
getHelper() |
int |
getIndex()
Get the layer index.
|
int |
getInputMiniBatchSize()
Get current/last input mini-batch size, as set by setInputMiniBatchSize(int)
|
int |
getIterationCount() |
Collection<TrainingListener> |
getListeners()
Get the iteration listeners for this layer.
|
INDArray |
getMaskArray() |
boolean |
isPretrainLayer()
Returns true if the layer can be trained in an unsupervised/pretrain manner (AE, VAE, etc)
|
void |
setCacheMode(CacheMode mode)
This method sets given CacheMode for current layer
|
void |
setEpochCount(int epochCount)
Set the current epoch count (number of epochs passed ) for the layer/network
|
void |
setIndex(int index)
Set the layer index.
|
void |
setInput(INDArray input,
LayerWorkspaceMgr workspaceMgr)
Set the layer input.
|
void |
setInputMiniBatchSize(int size)
Set current/last input mini-batch size.
Used for score and gradient calculations. |
void |
setIterationCount(int iterationCount)
Set the current iteration count (number of parameter updates) for the layer/network
|
void |
setListeners(Collection<TrainingListener> listeners)
Set the
TrainingListener s for this model. |
void |
setListeners(TrainingListener... listeners)
Set the
TrainingListener s for this model. |
void |
setMaskArray(INDArray maskArray)
Set the mask array.
|
Layer.Type |
type()
Returns the layer type
|
addListeners, applyConstraints, batchSize, clear, close, computeGradientAndScore, conf, fit, fit, getGradientsViewArray, getOptimizer, getParam, gradient, gradientAndScore, init, input, numParams, numParams, params, paramTable, paramTable, score, setBackpropGradientsViewArray, setConf, setParam, setParams, setParamsViewArray, setParamTable, update, update
getConfig, getGradientsViewArray, numParams, params, paramTable, updaterDivideByMinibatch
void setCacheMode(CacheMode mode)
mode
- double calcRegularizationScore(boolean backpropOnlyParams)
backpropOnlyParams
- If true: calculate regularization score based on backprop params only. If false: calculate
based on all params (including pretrain params, if any)Layer.Type type()
Pair<Gradient,INDArray> backpropGradient(INDArray epsilon, LayerWorkspaceMgr workspaceMgr)
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 managerINDArray activate(boolean training, LayerWorkspaceMgr workspaceMgr)
training
- training or test modeworkspaceMgr
- Workspace managerArrayType.ACTIVATIONS
workspace via the workspace managerINDArray activate(INDArray input, boolean training, LayerWorkspaceMgr mgr)
input
- the input to usetraining
- train or test modemgr
- Workspace manager.ArrayType.ACTIVATIONS
workspace via the workspace managerCollection<TrainingListener> getListeners()
void setListeners(TrainingListener... listeners)
TrainingListener
s for this model. If any listeners have previously been set, they will be
replaced by this methodsetListeners
in interface Model
void setListeners(Collection<TrainingListener> listeners)
TrainingListener
s for this model. If any listeners have previously been set, they will be
replaced by this methodsetListeners
in interface Model
void setIndex(int index)
int getIndex()
int getIterationCount()
int getEpochCount()
void setIterationCount(int iterationCount)
void setEpochCount(int epochCount)
void setInput(INDArray input, LayerWorkspaceMgr workspaceMgr)
void setInputMiniBatchSize(int size)
int getInputMiniBatchSize()
setInputMiniBatchSize(int)
void setMaskArray(INDArray maskArray)
feedForwardMaskArray(INDArray, MaskState, int)
should be used in
preference to this.maskArray
- Mask array to setINDArray getMaskArray()
boolean isPretrainLayer()
void clearNoiseWeightParams()
void allowInputModification(boolean allow)
allow
- If true: the input array is safe to modify. If false: the input array should be copied before it
is modified (i.e., in-place modifications are un-safe)Pair<INDArray,MaskState> feedForwardMaskArray(INDArray maskArray, MaskState currentMaskState, int minibatchSize)
maskArray
- Mask array to setcurrentMaskState
- Current state of the mask - see MaskState
minibatchSize
- 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)LayerHelper getHelper()
Copyright © 2021. All rights reserved.