|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
org.neuroph.core.NeuralNetwork
public class NeuralNetwork
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.
Layer
,
LearningRule
,
Serialized FormConstructor Summary | |
---|---|
NeuralNetwork()
Creates an instance of empty neural network. |
Method Summary | |
---|---|
void |
addLayer(int idx,
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 |
java.util.Vector<Neuron> |
getInputNeurons()
Gets reference to input neurons Vector. |
Layer |
getLayerAt(int idx)
Returns layer at specified index |
java.util.Vector<Layer> |
getLayers()
Returns getLayersIterator Vector collection |
int |
getLayersCount()
Returns number of layers in network |
java.util.Iterator<Layer> |
getLayersIterator()
Returns interface for iterating layers |
LearningRule |
getLearningRule()
Returns the learning algorithm of this network |
java.lang.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 |
java.util.Vector<java.lang.Double> |
getOutput()
Returns network output Vector. |
double[] |
getOutputAsArray()
Returns network output vector as double array |
java.util.Vector<Neuron> |
getOutputNeurons()
Returns reference to output neurons Vector. |
PluginBase |
getPlugin(java.lang.String pluginName)
Returns the requested plugin |
int |
indexOf(Layer layer)
Returns index position of the specified layer |
void |
learn(TrainingSet trainingSetToLearn)
Deprecated. |
void |
learnInNewThread(TrainingSet trainingSetToLearn)
Starts learning in a new thread to learn the specified training set, and immediately returns from method to the current thread execution |
void |
learnInNewThread(TrainingSet trainingSetToLearn,
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 |
void |
learnInSameThread(TrainingSet trainingSetToLearn)
Starts the learning in the current running thread to learn the specified training set, and returns from method when network is done learning |
void |
learnInSameThread(TrainingSet trainingSetToLearn,
LearningRule learningRule)
Starts the learning with specified learning rule in the current running thread to learn the specified training set, and returns from method when network is done learning |
static NeuralNetwork |
load(java.io.InputStream inputStream)
Loads neural network from the specified InputStream. |
static NeuralNetwork |
load(java.lang.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 |
removeLayer(Layer layer)
Removes specified layer from network |
void |
removeLayerAt(int idx)
Removes layer at specified index position from net |
void |
removePlugin(java.lang.String pluginName)
Removes the plugin with specified name |
void |
reset()
Resets the activation levels for whole network |
void |
resumeLearning()
Resumes paused learning - notifies the learning thread to continue |
void |
run()
Implementation of Runnable interface for calculating network in the separate thread. |
void |
save(java.lang.String filePath)
Saves neural network into the specified file. |
void |
setInput(double... inputArray)
Sets network input. |
void |
setInput(java.util.Vector<java.lang.Double> inputVector)
Sets network input. |
void |
setInputNeurons(java.util.Vector<Neuron> inputNeurons)
Sets reference to input neurons Vector |
void |
setLearningRule(LearningRule learningRule)
Sets learning algorithm for this network |
void |
setNetworkType(NeuralNetworkType type)
Sets type for this network |
void |
setOutputNeurons(java.util.Vector<Neuron> outputNeurons)
Sets reference to output neurons Vector. |
void |
stopLearning()
Stops learning |
java.lang.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 |
Constructor Detail |
---|
public NeuralNetwork()
Method Detail |
---|
public void addLayer(Layer layer)
layer
- layer to addpublic void addLayer(int idx, Layer layer)
idx
- index position to add layerlayer
- layer to addpublic void removeLayer(Layer layer)
layer
- layer to removepublic void removeLayerAt(int idx)
idx
- int value represents index postion of layer which should be
removedpublic java.util.Iterator<Layer> getLayersIterator()
public java.util.Vector<Layer> getLayers()
public Layer getLayerAt(int idx)
idx
- layer index position
public int indexOf(Layer layer)
layer
- requested Layer object
public int getLayersCount()
public void setInput(java.util.Vector<java.lang.Double> inputVector)
inputVector
- network input vectorpublic void setInput(double... inputArray)
inputArray
- network input as double arraypublic java.util.Vector<java.lang.Double> getOutput()
public double[] getOutputAsArray()
public void calculate()
public void reset()
public void run()
run
in interface java.lang.Runnable
public void learn(TrainingSet trainingSetToLearn)
trainingSetToLearn
- set of training elements to learnpublic void learnInNewThread(TrainingSet trainingSetToLearn)
trainingSetToLearn
- set of training elements to learnpublic void learnInNewThread(TrainingSet trainingSetToLearn, LearningRule learningRule)
trainingSetToLearn
- set of training elements to learnlearningRule
- learning algorithmpublic void learnInSameThread(TrainingSet trainingSetToLearn)
trainingSetToLearn
- set of training elements to learnpublic void learnInSameThread(TrainingSet trainingSetToLearn, LearningRule learningRule)
trainingSetToLearn
- set of training elements to learnlearningRule
- learning algorithm
*public void stopLearning()
public void pauseLearning()
public void resumeLearning()
public void randomizeWeights()
public NeuralNetworkType getNetworkType()
public void setNetworkType(NeuralNetworkType type)
type
- network typepublic java.util.Vector<Neuron> getInputNeurons()
public void setInputNeurons(java.util.Vector<Neuron> inputNeurons)
inputNeurons
- input neurons collectionpublic java.util.Vector<Neuron> getOutputNeurons()
public void setOutputNeurons(java.util.Vector<Neuron> outputNeurons)
outputNeurons
- output neurons collectionpublic LearningRule getLearningRule()
public void setLearningRule(LearningRule learningRule)
learningRule
- learning algorithm for this networkpublic java.lang.Thread getLearningThread()
public void notifyChange()
public void createConnection(Neuron fromNeuron, Neuron toNeuron, double weightVal)
fromNeuron
- neuron to connecttoNeuron
- neuron to connect toweightVal
- connection weight valuepublic java.lang.String toString()
toString
in class java.lang.Object
public void save(java.lang.String filePath)
filePath
- file path to save network intopublic static NeuralNetwork load(java.lang.String filePath)
filePath
- file path to load network from
public static NeuralNetwork load(java.io.InputStream inputStream)
inputStream
- input stream to load network from
public void addPlugin(PluginBase plugin)
plugin
- neural network plugin to addpublic PluginBase getPlugin(java.lang.String pluginName)
pluginName
- name of the plugin to get
public void removePlugin(java.lang.String pluginName)
pluginName
- name of the plugin to remove
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |