Class OutputLayer

  • All Implemented Interfaces:
    Layer, java.io.Serializable
    Direct Known Subclasses:
    SoftmaxOutputLayer

    public class OutputLayer
    extends AbstractLayer
    Output layer of a neural network, which gives the final output of a network. It is always the last layer in the network.
    Author:
    Zoran Sevarac
    See Also:
    Serialized Form
    • Constructor Detail

      • 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

        public OutputLayer​(int width,
                           ActivationType actType)
        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 outputs
        actType - activation function
      • OutputLayer

        public OutputLayer​(java.lang.String[] outputLabels)
        Creates an instance of output layer with specified width (number of outputs) which corresponds to number of labels and sigmoid activation function by default. Outputs are labeled with strings specified in labels parameter
        Parameters:
        outputLabels - labels for network's outputs
    • Method Detail

      • setOutputErrors

        public final void setOutputErrors​(float[] outputErrors)
      • init

        public void init()
        Description copied from class: AbstractLayer
        This method should implement layer initialization when layer is added to network (create weights, outputs, deltas, randomization etc.)
        Specified by:
        init in class AbstractLayer
      • 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 interface Layer
        Specified by:
        forward in class AbstractLayer
      • 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
        Specified by:
        backward in interface Layer
        Specified by:
        backward in class AbstractLayer
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object