The neuron class

This is the very foundation class for this chapter's code. According to the theory, an artificial neuron has the following attributes:

  • Inputs
  • Weights
  • Bias
  • Activation function
  • Output

It is also important to define one attribute that will be useful in future examples, that is the output before activation function. We then have the implementation of the following properties:

public class Neuron {
  protected ArrayList<Double> weight;
  private ArrayList<Double> input;
  private Double output;
  private Double outputBeforeActivation;
  private int numberOfInputs = 0;
  protected Double bias = 1.0;
  private IActivationFunction activationFunction;
  …
}

When instantiating a neuron, we need to specify how many inputs are going to feed values to it, and what ...

Get Neural Network Programming with Java - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.