Package deepnetts.net.layers
Class AbstractLayer<I extends TensorBase,O extends TensorBase,W extends TensorBase>
java.lang.Object
deepnetts.net.layers.AbstractLayer<I,O,W>
- Type Parameters:
O
- output tensor classW
- weights tensor class
- All Implemented Interfaces:
Layer<O>
,Serializable
- Direct Known Subclasses:
ConvolutionalLayer
,FlattenLayer
,FullyConnectedLayer
,InputLayer
,MaxPoolingLayer
,OutputLayer
public abstract class AbstractLayer<I extends TensorBase,O extends TensorBase,W extends TensorBase>
extends Object
implements Layer<O>, Serializable
Base class for different types of layers.
Provides common functionality for all type of layers: layer dimensions, inputs, outputs, connection
to previous and/or next layer, activation function and abstract methods for initialization, forward and backward pass.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
Applies weight changes to current weights Must be diferent for convolutional does nothing for MaxPooling Same for FullyConnected and OutputLayerabstract void
backward()
This method should implement backward pass in subclassesabstract void
forward()
This method should implement forward pass in subclassesfloat
final O
Returns layer deltas/errors (as a tensor).int
getDepth()
final TensorBase
int
float
float
float
float
float
getMode()
float
final O
Returns layer outputs (as a tensor).int
getWidth()
abstract void
init()
This method should implement layer initialization in subclasses, when a layer is added to the network (create weights, outputs, deltas, randomization etc.).void
boolean
boolean
void
setBatchMode
(boolean batchMode) void
setBatchSize
(int batchSize) void
void
setCudaHandles
(CudaHandles cudaHandles) final void
void
setL1Regularization
(float regL1) void
setL2Regularization
(float regL2) void
setLearningRate
(float learningRate) void
void
setMomentum
(float momentum) void
setNextlayer
(AbstractLayer nextlayer) void
setOptimizerType
(OptimizerType optType) final void
setOutputs
(O outputs) void
setPrevDeltaWeights
(W prevDeltaWeights) void
setPrevLayer
(AbstractLayer prevLayer) void
setThreadPool
(DeepNettsThreadPool threadPool) void
setTrainable
(boolean trainable) Set trainable to false to freeze learned weights.void
setWeights
(String weightStr) void
setWeights
(W weights)
-
Constructor Details
-
AbstractLayer
-
-
Method Details
-
init
public abstract void init()This method should implement layer initialization in subclasses, when a layer is added to the network (create weights, outputs, deltas, randomization etc.). -
forward
public abstract void forward()This method should implement forward pass in subclasses- Specified by:
forward
in interfaceLayer<I extends TensorBase>
-
backward
public abstract void backward()This method should implement backward pass in subclasses- Specified by:
backward
in interfaceLayer<I extends TensorBase>
-
applyWeightChanges
public abstract void applyWeightChanges()Applies weight changes to current weights Must be diferent for convolutional does nothing for MaxPooling Same for FullyConnected and OutputLayer -
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getDepth
public int getDepth() -
getPrevlayer
-
setPrevLayer
-
setNextlayer
-
getNextLayer
-
getWeights
-
getBiases
-
setBiases
-
getOutputs
Description copied from interface:Layer
Returns layer outputs (as a tensor).- Specified by:
getOutputs
in interfaceLayer<I extends TensorBase>
- Returns:
- layer output as a tensor
-
getDeltas
-
getGradients
-
getDeltaWeights
-
getPrevDeltaWeights
-
setPrevDeltaWeights
-
getPrevDeltaBiases
-
getDeltaBiases
-
setOutputs
-
setWeights
-
setWeights
-
setDeltas
-
getActivation
-
getOptimizer
-
getLearningRate
public float getLearningRate() -
setLearningRate
public void setLearningRate(float learningRate) -
isBatchMode
public boolean isBatchMode() -
setBatchMode
public void setBatchMode(boolean batchMode) -
getBatchSize
public float getBatchSize() -
setBatchSize
public void setBatchSize(int batchSize) -
setMomentum
public void setMomentum(float momentum) -
getMomentum
public float getMomentum() -
getOptimizerType
-
setOptimizerType
-
getActivationType
-
getL1WeightSum
public float getL1WeightSum() -
getL2WeightSum
public float getL2WeightSum() -
getL2Regularization
public float getL2Regularization() -
setL2Regularization
public void setL2Regularization(float regL2) -
getL1Regularization
public float getL1Regularization() -
setL1Regularization
public void setL1Regularization(float regL1) -
isTrainable
public boolean isTrainable() -
setTrainable
public void setTrainable(boolean trainable) Set trainable to false to freeze learned weights.- Parameters:
trainable
-
-
initTransientFields
public void initTransientFields() -
setCudaHandles
-
getMode
-
setMode
-
getForwardAccelerator
-
setThreadPool
-