Class SpaceToDepth
- java.lang.Object
-
- org.deeplearning4j.nn.layers.AbstractLayer<SpaceToDepthLayer>
-
- org.deeplearning4j.nn.layers.convolution.SpaceToDepth
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Layer
,Model
,Trainable
public class SpaceToDepth extends AbstractLayer<SpaceToDepthLayer>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.deeplearning4j.nn.api.Layer
Layer.TrainingMode, Layer.Type
-
-
Field Summary
-
Fields inherited from class org.deeplearning4j.nn.layers.AbstractLayer
cacheMode, conf, dataType, dropoutApplied, epochCount, index, input, inputModificationAllowed, iterationCount, maskArray, maskState, preOutput, trainingListeners
-
-
Constructor Summary
Constructors Constructor Description SpaceToDepth(NeuralNetConfiguration conf, DataType dataType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description INDArray
activate(boolean training, LayerWorkspaceMgr workspaceMgr)
Perform forward pass and return the activations array with the last set inputPair<Gradient,INDArray>
backpropGradient(INDArray epsilon, LayerWorkspaceMgr workspaceMgr)
Calculate the gradient relative to the error in the next layerdouble
calcRegularizationScore(boolean backpropParamsOnly)
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 functionvoid
clearNoiseWeightParams()
INDArray
getParam(String param)
Get the parameterGradient
gradient()
Get the gradient.boolean
isPretrainLayer()
Returns true if the layer can be trained in an unsupervised/pretrain manner (AE, VAE, etc)long
numParams()
The number of parameters for the modelINDArray
params()
Returns the parameters of the neural network as a flattened row vectorprotected INDArray
preOutput(boolean training, boolean forBackprop, LayerWorkspaceMgr workspaceMgr)
double
score()
The score for the modelvoid
setParams(INDArray params)
Set the parameters for this model.Layer.Type
type()
Returns the layer typevoid
update(INDArray gradient, String paramType)
Perform one update applying the gradient-
Methods inherited from class org.deeplearning4j.nn.layers.AbstractLayer
activate, addListeners, allowInputModification, applyConstraints, applyDropOutIfNecessary, applyMask, assertInputSet, backpropDropOutIfPresent, batchSize, clear, close, computeGradientAndScore, conf, feedForwardMaskArray, fit, fit, getConfig, getEpochCount, getGradientsViewArray, getHelper, getIndex, getInput, getInputMiniBatchSize, getListeners, getMaskArray, getOptimizer, gradientAndScore, init, input, layerConf, layerId, numParams, paramTable, paramTable, setBackpropGradientsViewArray, setCacheMode, setConf, setEpochCount, setIndex, setInput, setInputMiniBatchSize, setListeners, setListeners, setMaskArray, setParam, setParams, setParamsViewArray, setParamTable, update, updaterDivideByMinibatch
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.deeplearning4j.nn.api.Layer
getIterationCount, setIterationCount
-
-
-
-
Constructor Detail
-
SpaceToDepth
public SpaceToDepth(NeuralNetConfiguration conf, DataType dataType)
-
-
Method Detail
-
type
public Layer.Type type()
Description copied from interface:Layer
Returns the layer type- Specified by:
type
in interfaceLayer
- Overrides:
type
in classAbstractLayer<SpaceToDepthLayer>
- Returns:
-
backpropGradient
public Pair<Gradient,INDArray> backpropGradient(INDArray epsilon, LayerWorkspaceMgr workspaceMgr)
Description copied from interface:Layer
Calculate the gradient relative to the error in the next layer- Parameters:
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 manager- Returns:
- Pair
where Gradient is gradient for this layer, INDArray is epsilon (activation gradient) needed by next layer, but before element-wise multiply by sigmaPrime(z). So for standard feed-forward layer, if this layer is L, then return.getSecond() == dL/dIn = (w^(L)*(delta^(L))^T)^T. Note that the returned array should be placed in the ArrayType.ACTIVATION_GRAD
workspace via the workspace manager
-
preOutput
protected INDArray preOutput(boolean training, boolean forBackprop, LayerWorkspaceMgr workspaceMgr)
-
activate
public INDArray activate(boolean training, LayerWorkspaceMgr workspaceMgr)
Description copied from interface:Layer
Perform forward pass and return the activations array with the last set input- Parameters:
training
- training or test modeworkspaceMgr
- Workspace manager- Returns:
- the activation (layer output) of the last specified input. Note that the returned array should be placed
in the
ArrayType.ACTIVATIONS
workspace via the workspace manager
-
calcRegularizationScore
public double calcRegularizationScore(boolean backpropParamsOnly)
Description copied from interface:Layer
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- Specified by:
calcRegularizationScore
in interfaceLayer
- Overrides:
calcRegularizationScore
in classAbstractLayer<SpaceToDepthLayer>
- Parameters:
backpropParamsOnly
- If true: calculate regularization score based on backprop params only. If false: calculate based on all params (including pretrain params, if any)- Returns:
- the regularization score of
-
isPretrainLayer
public boolean isPretrainLayer()
Description copied from interface:Layer
Returns true if the layer can be trained in an unsupervised/pretrain manner (AE, VAE, etc)- Returns:
- true if the layer can be pretrained (using fit(INDArray), false otherwise
-
clearNoiseWeightParams
public void clearNoiseWeightParams()
-
gradient
public Gradient gradient()
Description copied from interface:Model
Get the gradient. Note that this method will not calculate the gradient, it will rather return the gradient that has been computed before. For calculating the gradient, seeModel.computeGradientAndScore(LayerWorkspaceMgr)
} .- Specified by:
gradient
in interfaceModel
- Overrides:
gradient
in classAbstractLayer<SpaceToDepthLayer>
- Returns:
- the gradient for this model, as calculated before
-
numParams
public long numParams()
Description copied from class:AbstractLayer
The number of parameters for the model- Specified by:
numParams
in interfaceModel
- Specified by:
numParams
in interfaceTrainable
- Overrides:
numParams
in classAbstractLayer<SpaceToDepthLayer>
- Returns:
- the number of parameters for the model
-
score
public double score()
Description copied from interface:Model
The score for the model- Specified by:
score
in interfaceModel
- Overrides:
score
in classAbstractLayer<SpaceToDepthLayer>
- Returns:
- the score for the model
-
update
public void update(INDArray gradient, String paramType)
Description copied from interface:Model
Perform one update applying the gradient- Specified by:
update
in interfaceModel
- Overrides:
update
in classAbstractLayer<SpaceToDepthLayer>
- Parameters:
gradient
- the gradient to apply
-
params
public INDArray params()
Description copied from class:AbstractLayer
Returns the parameters of the neural network as a flattened row vector- Specified by:
params
in interfaceModel
- Specified by:
params
in interfaceTrainable
- Overrides:
params
in classAbstractLayer<SpaceToDepthLayer>
- Returns:
- the parameters of the neural network
-
getParam
public INDArray getParam(String param)
Description copied from interface:Model
Get the parameter- Specified by:
getParam
in interfaceModel
- Overrides:
getParam
in classAbstractLayer<SpaceToDepthLayer>
- Parameters:
param
- the key of the parameter- Returns:
- the parameter vector/matrix with that particular key
-
setParams
public void setParams(INDArray params)
Description copied from interface:Model
Set the parameters for this model. This expects a linear ndarray which then be unpacked internally relative to the expected ordering of the model- Specified by:
setParams
in interfaceModel
- Overrides:
setParams
in classAbstractLayer<SpaceToDepthLayer>
- Parameters:
params
- the parameters for the model
-
-