Package deepnetts.net.layers
Class OutputLayer
- All Implemented Interfaces:
Layer<TensorBase>
,Serializable
- Direct Known Subclasses:
SoftmaxOutputLayer
Output layer of a neural network.
It is always the last layer in a neural network, and gives the final output of a network.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOutputLayer
(int width) Creates an instance of output layer with specified width (number of outputs) and sigmoid activation function by default.OutputLayer
(int width, ActivationType actType) Creates an instance of output layer with specified width (number of outputs) and specified activation function.OutputLayer
(String[] outputLabels, ActivationType actType) Creates an instance of output layer with specified width (number of outputs) and linear activation function by default. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Applies weight changes after one learning iteration or batchvoid
backward()
This method implements backward pass for the output layer.void
forward()
This method implements forward pass for the output layer.final LossType
final TensorBase
float
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
setLossType
(LossType lossType) final void
setOutputErrors
(TensorBase outputErrors) toString()
Methods inherited from class deepnetts.net.layers.AbstractLayer
getActivation, getActivationType, getBatchSize, getBiases, getDeltaBiases, getDeltas, getDeltaWeights, getDepth, getForwardAccelerator, getGradients, getHeight, getL1Regularization, getL1WeightSum, getL2Regularization, getL2WeightSum, getLearningRate, getMode, getMomentum, getNextLayer, getOptimizer, getOptimizerType, getOutputs, getPrevDeltaBiases, getPrevDeltaWeights, getPrevlayer, getWeights, getWidth, initTransientFields, isBatchMode, isTrainable, setBatchMode, setBatchSize, setBiases, setCudaHandles, setDeltas, setL1Regularization, setL2Regularization, setLearningRate, setMode, setMomentum, setNextlayer, setOptimizerType, setOutputs, setPrevDeltaWeights, setPrevLayer, setThreadPool, setTrainable, setWeights, setWeights
-
Constructor Details
-
OutputLayer
public OutputLayer(int width) Creates an instance of output layer with specified width (number of outputs) and sigmoid activation function by default. Outputs are labeled using generic names "Output1, 2, 3..."- Parameters:
width
- layer width which represents number of network outputs
-
OutputLayer
Creates an instance of output layer with specified width (number of outputs) and specified activation function. Outputs are labeled using generic names "Output1, 2, 3..."- Parameters:
width
- layer width whic represents number of network outputsactType
- activation function
-
OutputLayer
Creates an instance of output layer with specified width (number of outputs) and linear activation function by default. Typically linear activation is used for regression tasks, while sigmoid activation is used for binary classification problems.- Parameters:
outputLabels
- labels for network's outputs
-
-
Method Details
-
setOutputErrors
-
getOutputErrors
-
getLossType
-
setLossType
-
init
public void init()Description copied from class:AbstractLayer
This method should implement layer initialization in subclasses, when a layer is added to the network (create weights, outputs, deltas, randomization etc.).- Specified by:
init
in classAbstractLayer<TensorBase,
TensorBase, Tensor2D>
-
forward
public void forward()This method implements forward pass for the output layer. Calculates weighted input and layer outputs using sigmoid function.- Specified by:
forward
in interfaceLayer<TensorBase>
- Specified by:
forward
in classAbstractLayer<TensorBase,
TensorBase, Tensor2D>
-
backward
public void backward()This method implements backward pass for the output layer. http://peterroelants.github.io/posts/neural_network_implementation_intermezzo01/ http://neuralnetworksanddeeplearning.com/chap3.html#introducing_the_cross-entropy_cost_function http://neuralnetworksanddeeplearning.com/chap3.html- Specified by:
backward
in interfaceLayer<TensorBase>
- Specified by:
backward
in classAbstractLayer<TensorBase,
TensorBase, Tensor2D>
-
applyWeightChanges
public void applyWeightChanges()Applies weight changes after one learning iteration or batch- Specified by:
applyWeightChanges
in classAbstractLayer<TensorBase,
TensorBase, Tensor2D>
-
toString
-
getSingleOutInput
public float getSingleOutInput()
-