public class FrozenLayer extends BaseWrapperLayer
Layer.TrainingMode, Layer.Type
underlying
Constructor and Description |
---|
FrozenLayer(Layer insideLayer) |
Modifier and Type | Method and Description |
---|---|
org.nd4j.linalg.api.ndarray.INDArray |
activate(boolean training,
LayerWorkspaceMgr workspaceMgr)
Perform forward pass and return the activations array with the last set input
|
org.nd4j.linalg.api.ndarray.INDArray |
activate(org.nd4j.linalg.api.ndarray.INDArray input,
boolean training,
LayerWorkspaceMgr workspaceMgr)
Perform forward pass and return the activations array with the specified input
|
void |
applyConstraints(int iteration,
int epoch)
Apply any constraints to the model
|
org.nd4j.linalg.primitives.Pair<Gradient,org.nd4j.linalg.api.ndarray.INDArray> |
backpropGradient(org.nd4j.linalg.api.ndarray.INDArray epsilon,
LayerWorkspaceMgr workspaceMgr)
Calculate the gradient relative to the error in the next layer
|
double |
calcL1(boolean backpropOnlyParams)
Calculate the l1 regularization term
0.0 if regularization is not used. |
double |
calcL2(boolean backpropOnlyParams)
Calculate the l2 regularization term
0.0 if regularization is not used. |
Layer |
clone()
Clone the layer
|
void |
computeGradientAndScore(LayerWorkspaceMgr workspaceMgr)
Update the score
|
void |
fit()
All models have a fit method
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray data,
LayerWorkspaceMgr workspaceMgr)
Fit the model to the given data
|
Layer |
getInsideLayer() |
Gradient |
gradient()
Get the gradient.
|
org.nd4j.linalg.primitives.Pair<Gradient,Double> |
gradientAndScore()
Get the gradient and score
|
void |
init()
Init the model
|
protected String |
layerId() |
void |
logTestMode(boolean training) |
void |
logTestMode(Layer.TrainingMode training) |
void |
setBackpropGradientsViewArray(org.nd4j.linalg.api.ndarray.INDArray gradients)
Set the gradients array as a view of the full (backprop) network parameters
NOTE: this is intended to be used internally in MultiLayerNetwork and ComputationGraph, not by users.
|
void |
setCacheMode(CacheMode mode)
This method sets given CacheMode for current layer
|
void |
update(Gradient gradient)
Update layer weights and biases with gradient change
|
void |
update(org.nd4j.linalg.api.ndarray.INDArray gradient,
String paramType)
Perform one update applying the gradient
|
accumulateScore, addListeners, batchSize, clear, clearNoiseWeightParams, conf, feedForwardMaskArray, getEpochCount, getGradientsViewArray, getIndex, getInputMiniBatchSize, getIterationCount, getListeners, getMaskArray, getOptimizer, getParam, initParams, input, isPretrainLayer, numParams, numParams, params, paramTable, paramTable, score, setConf, setEpochCount, setIndex, setInput, setInputMiniBatchSize, setIterationCount, setListeners, setListeners, setMaskArray, setParam, setParams, setParamsViewArray, setParamTable, transpose, type, validateInput
public FrozenLayer(Layer insideLayer)
public void setCacheMode(CacheMode mode)
Layer
setCacheMode
in interface Layer
setCacheMode
in class BaseWrapperLayer
protected String layerId()
public double calcL2(boolean backpropOnlyParams)
Layer
calcL2
in interface Layer
calcL2
in class BaseWrapperLayer
backpropOnlyParams
- If true: calculate L2 based on backprop params only. If false: calculate
based on all params (including pretrain params, if any)public double calcL1(boolean backpropOnlyParams)
Layer
calcL1
in interface Layer
calcL1
in class BaseWrapperLayer
backpropOnlyParams
- If true: calculate L1 based on backprop params only. If false: calculate
based on all params (including pretrain params, if any)public org.nd4j.linalg.primitives.Pair<Gradient,org.nd4j.linalg.api.ndarray.INDArray> backpropGradient(org.nd4j.linalg.api.ndarray.INDArray epsilon, LayerWorkspaceMgr workspaceMgr)
Layer
backpropGradient
in interface Layer
backpropGradient
in class BaseWrapperLayer
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 org.nd4j.linalg.api.ndarray.INDArray activate(boolean training, LayerWorkspaceMgr workspaceMgr)
Layer
activate
in interface Layer
activate
in class BaseWrapperLayer
training
- training or test modeworkspaceMgr
- Workspace managerArrayType.ACTIVATIONS
workspace via the workspace managerpublic org.nd4j.linalg.api.ndarray.INDArray activate(org.nd4j.linalg.api.ndarray.INDArray input, boolean training, LayerWorkspaceMgr workspaceMgr)
Layer
activate
in interface Layer
activate
in class BaseWrapperLayer
input
- the input to usetraining
- train or test modeworkspaceMgr
- Workspace manager.ArrayType.ACTIVATIONS
workspace via the workspace managerpublic Layer clone()
Layer
clone
in interface Layer
clone
in class BaseWrapperLayer
public void fit()
Model
fit
in interface Model
fit
in class BaseWrapperLayer
public void update(Gradient gradient)
Model
update
in interface Model
update
in class BaseWrapperLayer
public void update(org.nd4j.linalg.api.ndarray.INDArray gradient, String paramType)
Model
update
in interface Model
update
in class BaseWrapperLayer
gradient
- the gradient to applypublic void computeGradientAndScore(LayerWorkspaceMgr workspaceMgr)
Model
computeGradientAndScore
in interface Model
computeGradientAndScore
in class BaseWrapperLayer
public void setBackpropGradientsViewArray(org.nd4j.linalg.api.ndarray.INDArray gradients)
Model
setBackpropGradientsViewArray
in interface Model
setBackpropGradientsViewArray
in class BaseWrapperLayer
gradients
- a 1 x nParams row vector that is a view of the larger (MLN/CG) gradients arraypublic void fit(org.nd4j.linalg.api.ndarray.INDArray data, LayerWorkspaceMgr workspaceMgr)
Model
fit
in interface Model
fit
in class BaseWrapperLayer
data
- the data to fit the model topublic Gradient gradient()
Model
Model#computeGradientAndScore()
.gradient
in interface Model
gradient
in class BaseWrapperLayer
public org.nd4j.linalg.primitives.Pair<Gradient,Double> gradientAndScore()
Model
gradientAndScore
in interface Model
gradientAndScore
in class BaseWrapperLayer
public void applyConstraints(int iteration, int epoch)
Model
applyConstraints
in interface Model
applyConstraints
in class BaseWrapperLayer
public void init()
init
in interface Model
init
in class BaseWrapperLayer
public void logTestMode(boolean training)
public void logTestMode(Layer.TrainingMode training)
public Layer getInsideLayer()
Copyright © 2018. All rights reserved.