Class OutputLayer
java.lang.Object
deepnetts.net.layers.AbstractLayer<TensorBase, TensorBase, Tensor2D>
deepnetts.net.layers.OutputLayer
- All Implemented Interfaces:
Backward, Forward, 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String[]protected LossTypeprotected booleanprotected TensorBaseFields inherited from class AbstractLayer
activation, activationType, backwardImpl, batchMode, batchSize, biases, cudaHandles, deltaBiases, deltas, deltaWeights, depth, forwardImpl, gradients, height, inputs, learningRate, mode, momentum, networkType, nextLayer, numThreads, optimizer, optimizerType, outputs, prevDeltaBiases, prevDeltaWeights, prevLayer, randomWeightsType, regL1, regL2, threadPool, trainable, weights, width -
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 TypeMethodDescriptionvoidApplies weight changes after one learning iteration or batchvoidbackward()This method implements backward pass for the output layer.voidforward()This method implements forward pass for the output layer.final LossTypefinal TensorBasefloatvoidinit()This method should implement layer initialization in subclasses, when a layer is added to the network (create weights, outputs, deltas, randomization etc.).voidvoidsetLossType(LossType lossType) final voidsetOutputErrors(TensorBase outputErrors) toString()Methods inherited from class AbstractLayer
getActivation, getActivationType, getBackwardAcc, getBatchSize, getBiases, getDeltaBiases, getDeltas, getDeltaWeights, getDepth, getForwardAcc, getGradients, getHeight, getL1Regularization, getL1WeightSum, getL2Regularization, getL2WeightSum, getLearningRate, getMode, getMomentum, getNetworkType, getNextLayer, getNumThreads, getOptimizer, getOptimizerType, getOutputs, getPrevDeltaBiases, getPrevDeltaWeights, getPrevlayer, getWeights, getWidth, isBatchMode, isTrainable, setActivationType, setBatchMode, setBatchSize, setBiases, setCudaHandles, setDeltas, setL1Regularization, setL2Regularization, setLearningRate, setMode, setMomentum, setNetworkType, setNextlayer, setOptimizerType, setOutputs, setPrevDeltaWeights, setPrevLayer, setThreadPool, setTrainable, setWeights, setWeights
-
Field Details
-
outputErrors
-
labels
-
lossType
-
multithreaded
protected transient boolean multithreaded -
forwardTasks
-
backwardTasks
-
-
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 type for this layer
-
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 outputsactType- activation function type for this layer
-
-
Method Details
-
setOutputErrors
-
getOutputErrors
-
getLossType
-
setLossType
-
init
public void init()Description copied from class:AbstractLayerThis method should implement layer initialization in subclasses, when a layer is added to the network (create weights, outputs, deltas, randomization etc.).- Specified by:
initin classAbstractLayer<TensorBase, TensorBase, Tensor2D>
-
initTransientFields
public void initTransientFields()- Overrides:
initTransientFieldsin 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:
forwardin interfaceForward- Specified by:
forwardin interfaceLayer<TensorBase>- Specified by:
forwardin 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:
backwardin interfaceBackward- Specified by:
backwardin interfaceLayer<TensorBase>- Specified by:
backwardin classAbstractLayer<TensorBase, TensorBase, Tensor2D>
-
applyWeightChanges
public void applyWeightChanges()Applies weight changes after one learning iteration or batch- Specified by:
applyWeightChangesin classAbstractLayer<TensorBase, TensorBase, Tensor2D>
-
toString
-
getSingleOutInput
public float getSingleOutInput()
-