Class Perceptron

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    Adaline

    public class Perceptron
    extends SupervisedLearning
    Perceptron is the first trainable neural network proposed. The network is formed by one matrix (Weights) and one vector (Bias). The output for the network is calculated by O = sign(W * pattern + b).
    See Also:
    Serialized Form
    • Field Detail

      • signum

        protected static final Sign signum
      • ins

        protected final int ins
      • outs

        protected final int outs
    • Constructor Detail

      • Perceptron

        public Perceptron​(int in,
                          int out)
        Constructor.
        Parameters:
        in - Number of inputs for the network = number of elements in the patterns.
        out - Number of outputs for the network.
      • Perceptron

        public Perceptron​(int in,
                          int out,
                          java.util.Random rand)
        Constructor.
        Parameters:
        in - Number of inputs for the network = number of elements in the patterns.
        out - Number of outputs for the network.
        rand - Random generator used for creating matrices
    • Method Detail

      • train

        public void train​(Column[] patterns,
                          Column[] answers,
                          double alpha,
                          int epochs,
                          int offset,
                          int length,
                          double minerror)
        Train the perceptron using the standard update rule:
        W = W + alpha.e.pattern^t
        b = b + alpha.e
        Specified by:
        train in class NeuralNetwork
        Parameters:
        patterns - The patterns to be learned.
        answers - The expected answers.
        alpha - The learning rate.
        epochs - The maximum number of iterations
        offset - The first pattern position
        length - How many patterns will be used.
        minerror - The minimal error expected.
      • simulate

        public Column simulate​(Column p)
        Description copied from class: NeuralNetwork
        Calculates the output for the pattern.
        Specified by:
        simulate in class NeuralNetwork
        Parameters:
        p - Pattern to use as input.
        Returns:
        The output for the neural network.
      • simulate

        public void simulate​(Column pattern,
                             Column result)
        Calculate the output for the pattern and left the result on result. result = signum(W * pattern + b)
        Specified by:
        simulate in class NeuralNetwork
        Parameters:
        pattern - The input pattern
        result - The output result.
      • getWeights

        public Matrix getWeights()