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 voidApplies weight changes to current weights Must be diferent for convolutional does nothing for MaxPooling Same for FullyConnected and OutputLayerabstract voidbackward()This method should implement backward pass in subclassesabstract voidforward()This method should implement forward pass in subclassesfloatfinal OReturns layer deltas/errors (as a tensor).intgetDepth()final TensorBaseintfloatfloatfloatfloatfloatgetMode()floatfinal OReturns layer outputs (as a tensor).intgetWidth()abstract voidinit()This method should implement layer initialization in subclasses, when a layer is added to the network (create weights, outputs, deltas, randomization etc.).voidbooleanbooleanvoidsetBatchMode(boolean batchMode) voidsetBatchSize(int batchSize) voidvoidsetCudaHandles(CudaHandles cudaHandles) final voidvoidsetL1Regularization(float regL1) voidsetL2Regularization(float regL2) voidsetLearningRate(float learningRate) voidvoidsetMomentum(float momentum) voidsetNextlayer(AbstractLayer nextlayer) voidsetOptimizerType(OptimizerType optType) final voidsetOutputs(O outputs) voidsetPrevDeltaWeights(W prevDeltaWeights) voidsetPrevLayer(AbstractLayer prevLayer) voidsetThreadPool(DeepNettsThreadPool threadPool) voidsetTrainable(boolean trainable) Set trainable to false to freeze learned weights.voidsetWeights(String weightStr) voidsetWeights(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:
forwardin interfaceLayer<I extends TensorBase>
-
backward
public abstract void backward()This method should implement backward pass in subclasses- Specified by:
backwardin 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:LayerReturns layer outputs (as a tensor).- Specified by:
getOutputsin 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
-