Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.neuroph.core
Class NeuralNetwork

    java.lang.Object
      java.util.Observable
          org.neuroph.core.NeuralNetwork

All Implemented Interfaces:
  Serializable

Direct Known Subclasses:
  Adaline, BAM, CompetitiveNetwork, Hopfield, Instar, Kohonen, MaxNet, MultiLayerPerceptron, NeuroFuzzyPerceptron, Outstar, Perceptron, RbfNetwork, SupervisedHebbianNetwork, UnsupervisedHebbianNetwork

    public class NeuralNetwork

extends Observable
implements Serializable

     Base class for artificial neural networks. It provides generic structure and functionality
     for the neural networks. Neural network contains a collection of neuron layers and learning rule.
     Custom neural networks are created by deriving from this class, creating layers of interconnected network specific neurons,
     and setting network specific learning rule.

Author:
  Zoran Sevarac
See Also:
  `Layer`, `LearningRule`, Serialized Form

Field Summary
`protected double[]` | `output` Neural network output buffer

Constructor Summary
`NeuralNetwork()` Creates an instance of empty neural network.

Method Summary
`void` | `addLayer(int index, Layer layer)` Adds layer to specified index position in network
`void` | `addLayer(Layer layer)` Adds layer to neural network
`void` | `addPlugin(PluginBase plugin)` Adds plugin to neural network
`void` | `calculate()` Performs calculation on whole network
`void` | `createConnection(Neuron fromNeuron, Neuron toNeuron, double weightVal)` Creates connection with specified weight value between specified neurons
`Neuron[]` | `getInputNeurons()` Returns input neurons
`int` | `getInputsCount()` Gets number of input neurons
`String` | `getLabel()` Get network label
`Layer` | `getLayerAt(int index)` Returns layer at specified index
`Layer[]` | `getLayers()` Returns layers array
`int` | `getLayersCount()` Returns number of layers in network
`LearningRule` | `getLearningRule()` Returns the learning algorithm of this network
`Thread` | `getLearningThread()` Returns the current learning thread (if it is learning in the new thread Check what happens if it learns in the same thread)
`NeuralNetworkType` | `getNetworkType()` Returns type of this network
`double[]` | `getOutput()` Returns network output Vector.
`Neuron[]` | `getOutputNeurons()` Returns output neurons
`int` | `getOutputsCount()`
`PluginBase` | `getPlugin(Class pluginClass)` Returns the requested plugin
`int` | `indexOf(Layer layer)` Returns index position of the specified layer
`void` | `learn(DataSet trainingSet)` Learn the specified training set
`void` | `learn(DataSet trainingSet, LearningRule learningRule)` Learn the specified training set, using specified learning rule
`void` | `learnInNewThread(DataSet trainingSet)` Starts learning in a new thread to learn the specified training set, and immediately returns from method to the current thread execution
`void` | `learnInNewThread(DataSet trainingSet, LearningRule learningRule)` Starts learning with specified learning rule in new thread to learn the specified training set, and immediately returns from method to the current thread execution
`static NeuralNetwork` | `load(InputStream inputStream)` Loads neural network from the specified InputStream.
`static NeuralNetwork` | `load(String filePath)` Loads neural network from the specified file.
`void` | `notifyChange()` Notifies observers about some change
`void` | `pauseLearning()` Pause the learning - puts learning thread in wait state.
`void` | `randomizeWeights()` Randomizes connection weights for the whole network
`void` | `randomizeWeights(double minWeight, double maxWeight)` Randomizes connection weights for the whole network within specified value range
`void` | `randomizeWeights(Random random)` Randomizes connection weights for the whole network using specified random generator
`void` | `randomizeWeights(WeightsRandomizer randomizer)` Randomizes connection weights for the whole network using specified randomizer
`void` | `removeLayer(Layer layer)` Removes specified layer from network
`void` | `removeLayerAt(int index)` Removes layer at specified index position from net
`void` | `removePlugin(Class pluginClass)` Removes the plugin with specified name
`void` | `reset()` Resets the activation levels for whole network
`void` | `resumeLearning()` Resumes paused learning - notifies the learning rule to continue
`void` | `save(String filePath)` Saves neural network into the specified file.
`void` | `setInput(double... inputVector)` Sets network input.
`void` | `setInputNeurons(Neuron[] inputNeurons)` Sets input neurons
`void` | `setLabel(String label)` Set network label
`void` | `setLearningRule(LearningRule learningRule)` Sets learning algorithm for this network
`void` | `setNetworkType(NeuralNetworkType type)` Sets type for this network
`void` | `setOutputNeurons(Neuron[] outputNeurons)` Sets output neurons
`void` | `stopLearning()` Stops learning
`String` | `toString()`

Methods inherited from class java.util.Observable
`addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### output

    protected double[] output

  Neural network output buffer

Constructor Detail

### NeuralNetwork

    public NeuralNetwork()

  Creates an instance of empty neural network.

Method Detail

### addLayer

    public void addLayer(Layer layer)

  Adds layer to neural network

  Parameters:
    `layer` - layer to add

### addLayer

    public void addLayer(int index,
                         Layer layer)

  Adds layer to specified index position in network

  Parameters:
    `index` - index position to add layer
    `layer` - layer to add

### removeLayer

    public void removeLayer(Layer layer)

  Removes specified layer from network

  Parameters:
    `layer` - layer to remove

### removeLayerAt

    public void removeLayerAt(int index)

  Removes layer at specified index position from net

  Parameters:
    `index` - int value represents index postion of layer which should be removed

### getLayers

    public final Layer[] getLayers()

  Returns layers array

  Returns:
    array of layers

### getLayerAt

    public Layer getLayerAt(int index)

  Returns layer at specified index

  Parameters:
    `index` - layer index position
  Returns:
    layer at specified index position

### indexOf

    public int indexOf(Layer layer)

  Returns index position of the specified layer

  Parameters:
    `layer` - requested Layer object
  Returns:
    layer position index

### getLayersCount

    public int getLayersCount()

  Returns number of layers in network

  Returns:
    number of layes in net

### setInput

    public void setInput(double... inputVector)
                  throws VectorSizeMismatchException

  Sets network input. Input is an array of double values.

  Parameters:
    `inputVector` - network input as double array
  Throws:
    `VectorSizeMismatchException`

### getOutput

    public double[] getOutput()

  Returns network output Vector. Output Vector is a collection of Double values.

  Returns:
    network output Vector

### calculate

    public void calculate()

  Performs calculation on whole network

### reset

    public void reset()

  Resets the activation levels for whole network

### learn

    public void learn(DataSet trainingSet)

  Learn the specified training set

  Parameters:
    `trainingSet` - set of training elements to learn

### learn

    public void learn(DataSet trainingSet,
                      LearningRule learningRule)

  Learn the specified training set, using specified learning rule

  Parameters:
    `trainingSet` - set of training elements to learn
    `learningRule` - instance of learning rule to use for learning

### learnInNewThread

    public void learnInNewThread(DataSet trainingSet)

  Starts learning in a new thread to learn the specified training set, and immediately returns from method to the current thread execution

  Parameters:
    `trainingSet` - set of training elements to learn

### learnInNewThread

    public void learnInNewThread(DataSet trainingSet,
                                 LearningRule learningRule)

  Starts learning with specified learning rule in new thread to learn the specified training set, and immediately returns from method to the current thread execution

  Parameters:
    `trainingSet` - set of training elements to learn
    `learningRule` - learning algorithm

### stopLearning

    public void stopLearning()

  Stops learning

### pauseLearning

    public void pauseLearning()

  Pause the learning - puts learning thread in wait state. Makes sense only wen learning is done in new thread with learnInNewThread() method

### resumeLearning

    public void resumeLearning()

  Resumes paused learning - notifies the learning rule to continue

### randomizeWeights

    public void randomizeWeights()

  Randomizes connection weights for the whole network

### randomizeWeights

    public void randomizeWeights(double minWeight,
                                 double maxWeight)

  Randomizes connection weights for the whole network within specified value range

### randomizeWeights

    public void randomizeWeights(Random random)

  Randomizes connection weights for the whole network using specified random generator

### randomizeWeights

    public void randomizeWeights(WeightsRandomizer randomizer)

  Randomizes connection weights for the whole network using specified randomizer

  Parameters:
    `randomizer` - random weight generator to use

### getNetworkType

    public NeuralNetworkType getNetworkType()

  Returns type of this network

  Returns:
    network type

### setNetworkType

    public void setNetworkType(NeuralNetworkType type)

  Sets type for this network

  Parameters:
    `type` - network type

### getInputNeurons

    public Neuron[] getInputNeurons()

  Returns input neurons

  Returns:
    input neurons

### getInputsCount

    public int getInputsCount()

  Gets number of input neurons

  Returns:
    number of input neurons

### setInputNeurons

    public void setInputNeurons(Neuron[] inputNeurons)

  Sets input neurons

  Parameters:
    `inputNeurons` - array of input neurons

### getOutputNeurons

    public Neuron[] getOutputNeurons()

  Returns output neurons

  Returns:
    array of output neurons

### getOutputsCount

    public int getOutputsCount()

### setOutputNeurons

    public void setOutputNeurons(Neuron[] outputNeurons)

  Sets output neurons

  Parameters:
    `outputNeurons` - output neurons collection

### getLearningRule

    public LearningRule getLearningRule()

  Returns the learning algorithm of this network

  Returns:
    algorithm for network training

### setLearningRule

    public void setLearningRule(LearningRule learningRule)

  Sets learning algorithm for this network

  Parameters:
    `learningRule` - learning algorithm for this network

### getLearningThread

    public Thread getLearningThread()

  Returns the current learning thread (if it is learning in the new thread Check what happens if it learns in the same thread)

### notifyChange

    public void notifyChange()

  Notifies observers about some change

### createConnection

    public void createConnection(Neuron fromNeuron,
                                 Neuron toNeuron,
                                 double weightVal)

  Creates connection with specified weight value between specified neurons

  Parameters:
    `fromNeuron` - neuron to connect
    `toNeuron` - neuron to connect to
    `weightVal` - connection weight value

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### save

    public void save(String filePath)

  Saves neural network into the specified file.

  Parameters:
    `filePath` - file path to save network into

### load

    public static NeuralNetwork load(String filePath)

  Loads neural network from the specified file.

  Parameters:
    `filePath` - file path to load network from
  Returns:
    loaded neural network as NeuralNetwork object

### load

    public static NeuralNetwork load(InputStream inputStream)

  Loads neural network from the specified InputStream.

  Parameters:
    `inputStream` - input stream to load network from
  Returns:
    loaded neural network as NeuralNetwork object

### addPlugin

    public void addPlugin(PluginBase plugin)

  Adds plugin to neural network

  Parameters:
    `plugin` - neural network plugin to add

### getPlugin

    public PluginBase getPlugin(Class pluginClass)

  Returns the requested plugin

  Parameters:
    `pluginClass` - class of the plugin to get
  Returns:
    instance of specified plugin class

### removePlugin

    public void removePlugin(Class pluginClass)

  Removes the plugin with specified name

  Parameters:
    `pluginClass` - class of the plugin to remove

### getLabel

    public String getLabel()

  Get network label

  Returns:
    network label

### setLabel

    public void setLabel(String label)

  Set network label

  Parameters:
    `label` - network label to set

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012. All Rights Reserved.