|
||||||||||
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 FormField 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 |
---|
protected double[] output
Constructor Detail |
---|
public NeuralNetwork()
Method Detail |
---|
public void addLayer(Layer layer)
layer
- layer to addpublic void addLayer(int index, Layer layer)
index
- index position to add layerlayer
- layer to addpublic void removeLayer(Layer layer)
layer
- layer to removepublic void removeLayerAt(int index)
index
- int value represents index postion of layer which should be
removedpublic final Layer[] getLayers()
public Layer getLayerAt(int index)
index
- layer index position
public int indexOf(Layer layer)
layer
- requested Layer object
public int getLayersCount()
public void setInput(double... inputVector) throws VectorSizeMismatchException
inputVector
- network input as double array
VectorSizeMismatchException
public double[] getOutput()
public void calculate()
public void reset()
public void learn(DataSet trainingSet)
trainingSet
- set of training elements to learnpublic void learn(DataSet trainingSet, LearningRule learningRule)
trainingSet
- set of training elements to learnlearningRule
- instance of learning rule to use for learningpublic void learnInNewThread(DataSet trainingSet)
trainingSet
- set of training elements to learnpublic void learnInNewThread(DataSet trainingSet, LearningRule learningRule)
trainingSet
- set of training elements to learnlearningRule
- learning algorithmpublic void stopLearning()
public void pauseLearning()
public void resumeLearning()
public void randomizeWeights()
public void randomizeWeights(double minWeight, double maxWeight)
public void randomizeWeights(Random random)
public void randomizeWeights(WeightsRandomizer randomizer)
randomizer
- random weight generator to usepublic NeuralNetworkType getNetworkType()
public void setNetworkType(NeuralNetworkType type)
type
- network typepublic Neuron[] getInputNeurons()
public int getInputsCount()
public void setInputNeurons(Neuron[] inputNeurons)
inputNeurons
- array of input neuronspublic Neuron[] getOutputNeurons()
public int getOutputsCount()
public void setOutputNeurons(Neuron[] outputNeurons)
outputNeurons
- output neurons collectionpublic LearningRule getLearningRule()
public void setLearningRule(LearningRule learningRule)
learningRule
- learning algorithm for this networkpublic 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 String toString()
toString
in class Object
public void save(String filePath)
filePath
- file path to save network intopublic static NeuralNetwork load(String filePath)
filePath
- file path to load network from
public static NeuralNetwork load(InputStream inputStream)
inputStream
- input stream to load network from
public void addPlugin(PluginBase plugin)
plugin
- neural network plugin to addpublic PluginBase getPlugin(Class pluginClass)
pluginClass
- class of the plugin to get
public void removePlugin(Class pluginClass)
pluginClass
- class of the plugin to removepublic String getLabel()
public void setLabel(String label)
label
- network label to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |