The Encog Project

org.encog.neural.networks
Class BasicNetwork

java.lang.Object
  extended by org.encog.neural.networks.BasicNetwork
All Implemented Interfaces:
java.io.Serializable, Network, EncogPersistedObject

public class BasicNetwork
extends java.lang.Object
implements java.io.Serializable, Network, EncogPersistedObject

BasicNetwork: This class implements a neural network. This class works in conjunction the Layer classes. Layers are added to the BasicNetwork to specify the structure of the neural network. The first layer added is the input layer, the final layer added is the output layer. Any layers added between these two layers are the hidden layers.

See Also:
Serialized Form

Constructor Summary
BasicNetwork()
          Construct an empty neural network.
 
Method Summary
 void addLayer(Layer layer)
          Add a layer to the neural network.
 double calculateError(NeuralDataSet data)
          Calculate the error for this neural network.
 int calculateNeuronCount()
          Calculate the total number of neurons in the network across all layers.
 java.lang.Object clone()
          Return a clone of this neural network.
 BasicNetwork cloneStructure()
          Return a clone of the structure of this neural network.
 NeuralData compute(NeuralData input)
          Compute the output for a given input to the neural network.
 boolean equals(BasicNetwork other)
          Compare the two neural networks.
 int getHiddenLayerCount()
          Get the count for how many hidden layers are present.
 java.util.Collection<Layer> getHiddenLayers()
          Get a collection of the hidden layers in the network.
 Layer getInputLayer()
          Get the input layer.
 java.util.List<Layer> getLayers()
          Get all layers.
 Layer getOutputLayer()
          Get the output layer.
 int getWeightMatrixSize()
          Get the size of the weight and threshold matrix.
 int hashCode()
          Generate a hash code.
 void reset()
          Reset the weight matrix and the thresholds.
 int winner(NeuralData input)
          Determine the winner for the specified input.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicNetwork

public BasicNetwork()
Construct an empty neural network.

Method Detail

addLayer

public void addLayer(Layer layer)
Add a layer to the neural network. The first layer added is the input layer, the last layer added is the output layer.

Parameters:
layer - The layer to be added.

calculateError

public double calculateError(NeuralDataSet data)
Calculate the error for this neural network. The error is calculated using root-mean-square(RMS).

Parameters:
data - The training set.
Returns:
The error percentage.

calculateNeuronCount

public int calculateNeuronCount()
Calculate the total number of neurons in the network across all layers.

Returns:
The neuron count.

clone

public java.lang.Object clone()
Return a clone of this neural network. Including structure, weights and threshold values.

Overrides:
clone in class java.lang.Object
Returns:
A cloned copy of the neural network.

cloneStructure

public BasicNetwork cloneStructure()
Return a clone of the structure of this neural network.

Returns:
A cloned copy of the structure of the neural network.

compute

public NeuralData compute(NeuralData input)
Compute the output for a given input to the neural network.

Specified by:
compute in interface Network
Parameters:
input - The input provide to the neural network.
Returns:
The results from the output neurons.

equals

public boolean equals(BasicNetwork other)
Compare the two neural networks. For them to be equal they must be of the same structure, and have the same matrix values.

Parameters:
other - The other neural network.
Returns:
True if the two networks are equal.

getHiddenLayerCount

public int getHiddenLayerCount()
Get the count for how many hidden layers are present.

Returns:
The hidden layer count.

getHiddenLayers

public java.util.Collection<Layer> getHiddenLayers()
Get a collection of the hidden layers in the network.

Returns:
The hidden layers.

getInputLayer

public Layer getInputLayer()
Get the input layer.

Returns:
The input layer.

getLayers

public java.util.List<Layer> getLayers()
Get all layers.

Returns:
All layers.

getOutputLayer

public Layer getOutputLayer()
Get the output layer.

Returns:
The output layer.

getWeightMatrixSize

public int getWeightMatrixSize()
Get the size of the weight and threshold matrix.

Returns:
The size of the matrix.

reset

public void reset()
Reset the weight matrix and the thresholds.

Throws:
MatrixException

winner

public int winner(NeuralData input)
Determine the winner for the specified input. This is the number of the winning neuron.

Parameters:
input - The input patter to present to the neural network.
Returns:
The winning neuron.

hashCode

public int hashCode()
Generate a hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
THe hash code.

The Encog Project