neural.net
Class Network

java.lang.Object
  extended by neural.net.Network
All Implemented Interfaces:
java.io.Serializable

public class Network
extends java.lang.Object
implements java.io.Serializable

Representation of an Artificial Neural Network The number of inputs, outputs, and neurons in the hidden layer are configurable and the Activation Function can be configured too with any class that implements the ActivationFunction interface. This Network is restricted to use exactly one hidden layer

Version:
1.0.0
Author:
Jonathan Reimels
See Also:
Serialized Form

Constructor Summary
Network(int inputCount, int outputCount, int hiddenLayerNeuronCount)
          Constructor - uses default ActivationFunction (Sigmoid)
Network(int inputCount, int outputCount, int hiddenLayerNeuronCount, ActivationFunction activationFunction)
          Constructor
 
Method Summary
 double[] fire(double[] inputs)
          Fire each layer in the Network
 ActivationFunction getActivationFunction()
          Get the instance of the ActivationFunction being used
 Layer getHiddenLayer()
          Get the hidden layer
 int getInputCount()
          Get number of inputs
 double[] getLastOutputs()
          Get last output values
 int getOutputCount()
          Get number of outputs
 Layer getOutputLayer()
          Get the output layer
static Network load(java.io.File file)
          Load a Network from a file
 void save(java.io.File file)
          Save the neural network to a file, this should be used after training is complete so that the Network can be reloaded and training will not need to be redone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Network

public Network(int inputCount,
               int outputCount,
               int hiddenLayerNeuronCount,
               ActivationFunction activationFunction)
Constructor

Parameters:
inputCount - - number of inputs
outputCount - - number of output neurons
hiddenLayerNeuronCount - - number of neurons in the hidden layer
activationFunction - - class implementing ActivationFunction, used to calculate activation value of neuron

Network

public Network(int inputCount,
               int outputCount,
               int hiddenLayerNeuronCount)
Constructor - uses default ActivationFunction (Sigmoid)

Parameters:
inputCount - - number of inputs
outputCount - - number of output neurons
hiddenLayerNeuronCount - - number of neurons in the hidden layer
Method Detail

getInputCount

public int getInputCount()
Get number of inputs

Returns:
input count

getOutputCount

public int getOutputCount()
Get number of outputs

Returns:
output count

getLastOutputs

public double[] getLastOutputs()
Get last output values

Returns:
outputs

getActivationFunction

public ActivationFunction getActivationFunction()
Get the instance of the ActivationFunction being used

Returns:
ActivationFunction

getHiddenLayer

public Layer getHiddenLayer()
Get the hidden layer

Returns:
Layer

getOutputLayer

public Layer getOutputLayer()
Get the output layer

Returns:
Layer

fire

public double[] fire(double[] inputs)
              throws java.lang.Exception
Fire each layer in the Network

Parameters:
inputs - - inputs to be passed to the first layer
Returns:
output
Throws:
java.lang.Exception - - throws an exception if input length is incorrect

save

public void save(java.io.File file)
          throws java.lang.Exception
Save the neural network to a file, this should be used after training is complete so that the Network can be reloaded and training will not need to be redone

Parameters:
file - - File to save
Throws:
FileNotFoundException, - IOException
java.lang.Exception

load

public static Network load(java.io.File file)
                    throws java.lang.Exception
Load a Network from a file

Parameters:
file - - File to load
Returns:
Network
Throws:
FileNotFoundException, - IOException, ClassNotFoundException
java.lang.Exception