|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.joone.net.NeuralNet
public class NeuralNet
This object represents a container of a neural network, giving to the developer the possibility to manage a neural network as a whole. Thanks to it, a neural network can be saved and restored using an unique writeObject and readObject command, without be worried about its internal composition. Not only this, because using a NeuralNet object, we can also easily transport a neural network on remote machines and runnit there, writing only few and generalized java code.
Field Summary | |
---|---|
static int |
HIDDEN_LAYER
|
static int |
INPUT_LAYER
|
protected java.util.Vector |
listeners
|
static int |
OUTPUT_LAYER
|
protected int |
patternNumber
The number of the current pattern being chased through the network |
Constructor Summary | |
---|---|
NeuralNet()
Creates new NeuralNet |
Method Summary | |
---|---|
boolean |
addInputSynapse(InputPatternListener p1)
Adds a new input synapse to the layer |
void |
addLayer(Layer layer)
|
void |
addLayer(Layer layer,
int tier)
|
void |
addNeuralNetListener(NeuralNetListener listener)
|
void |
addNoise(double p1)
Adds a noise to the biases of the layer and to all the input synapses connected |
boolean |
addOutputSynapse(OutputPatternListener p1)
Adds a new output synapse to the layer |
Layer[] |
calculateOrderedLayers()
This method calculates the order of the layers of the network, from the input to the output. |
java.util.TreeSet |
check()
Compiles all layers' check messages. |
void |
cicleTerminated(NeuralNetEvent e)
To override. |
NeuralNet |
cloneNet()
Creates a copy of the contained neural network |
NeuralLayer |
copyInto(NeuralLayer p1)
Not implemented. |
void |
errorChanged(NeuralNetEvent e)
To override. |
protected void |
fastContinue()
This method restore the running of the neural network in single-thread mode, starting from the epoch at which it had been previously stopped. |
protected void |
fastRun()
This method runs the neural network in single-thread mode. |
protected void |
fastRun(int firstEpoch,
boolean continuation)
This method runs the neural network in single-thread mode starting from the epoch passed as parameter. |
Layer |
findInputLayer()
Returns the input layer, by searching for it following the rules written in Layer.isInputLayer. |
Layer |
findOutputLayer()
Returns the output layer by searching for it following the rules written in Layer.isOutputLayer. |
java.util.Vector |
getAllInputs()
Returns the vector of the input listeners |
java.util.Vector |
getAllOutputs()
Returns the vector of the input listeners |
Matrix |
getBias()
Return the bias matrix |
NeuralNetAttributes |
getDescriptor()
|
Layer |
getInputLayer()
Returns the input layer of the network. |
java.lang.String[] |
getKeys()
Return all the keys of the parameters contained in the net. |
Layer |
getLayer(java.lang.String layerName)
|
java.lang.String |
getLayerName()
Returns the name of the layer |
java.util.Vector |
getLayers()
|
java.util.Vector |
getListeners()
|
MacroInterface |
getMacroPlugin()
Getter for property macroPlugin. |
Monitor |
getMonitor()
Returns the monitor object |
static java.lang.Integer |
getNumericVersion()
Method to get the numeric version. |
protected int |
getNumOfstepCounters()
|
Layer[] |
getOrderedLayers()
|
Layer |
getOutputLayer()
Returns the output layer of the network. |
java.lang.Object |
getParam(java.lang.String key)
Gets a custom parameter from the neural net. |
int |
getPatternNumber()
Retrieve the number of the current pattern being pumped through the network |
int |
getRows()
Returns the dimension (# of neurons) of the Layer |
protected java.lang.Thread |
getSingleThread()
|
ComparingElement |
getTeacher()
|
static java.lang.String |
getVersion()
Method to get the version. |
void |
go()
Runs the network in async mode (i.e. |
void |
go(boolean sync)
Runs the network. |
void |
go(boolean singleThreadMode,
boolean sync)
Runs the network. |
boolean |
isRunning()
Returns true if the network is running |
boolean |
isScriptingEnabled()
Gets if the scripting engine is enabled |
void |
join()
Waits for all the termination of all running Threads |
void |
netStarted(NeuralNetEvent e)
To override. |
void |
netStopped(NeuralNetEvent e)
To override. |
void |
netStoppedError(NeuralNetEvent e,
java.lang.String error)
Stops the execution threads and resets all the layers in the event of an crtitical network error. |
void |
randomize(double amplitude)
|
void |
removeAllInputs()
Remove all the input listeners of the net |
void |
removeAllListeners()
|
void |
removeAllOutputs()
Remove all the output listeners of the net |
void |
removeInputSynapse(InputPatternListener p1)
Remove an input Listener |
void |
removeLayer(Layer layer)
|
void |
removeNeuralNetListener(NeuralNetListener listener)
|
void |
removeOutputSynapse(OutputPatternListener p1)
Remove an output listener from the layer |
void |
reset()
Resets all the StreamInputLayer of the net. |
void |
resetInitialState()
Reset the initial state of any context layers |
void |
resetInput()
Resets all the StreamInputLayer of the net |
void |
restore()
Continue the execution of the network after a stop() invocation. |
void |
restore(boolean sync)
Continue the execution of the network after a stop() invocation. |
void |
setAllInputs(java.util.Vector p1)
Sets the vector that contains all the input listeners. |
void |
setAllOutputs(java.util.Vector p1)
Sets the vector that contains all the output listeners. |
void |
setBias(Matrix p1)
Sets the matrix of biases |
void |
setDescriptor(NeuralNetAttributes newdescriptor)
|
void |
setInputLayer(Layer newLayer)
|
void |
setLayerName(java.lang.String p1)
Sets the name of the layer |
void |
setLayers(java.util.Vector newlayers)
Permits to initialize a neural network with a Vector containing layers. |
void |
setLayersList(java.util.List list)
Permits to initialize a neural network with an List containing layers. |
void |
setListeners(java.util.Vector listeners)
Not implemented. |
void |
setMacroPlugin(MacroInterface macroPlugin)
Setter for property macroPlugin. |
void |
setMonitor(Monitor p1)
Sets the monitor object |
void |
setOrderedLayers(Layer[] orderedLayers)
This method permits to set externally a particular order to traverse the Layers. |
void |
setOutputLayer(Layer newLayer)
|
void |
setParam(java.lang.String key,
java.lang.Object obj)
Sets a custom parameter of the neural net. |
void |
setRows(int p1)
Sets the dimension (# of neurons) of the Layer |
void |
setScriptingEnabled(boolean enabled)
Enable/disable the scripting engine for the net. |
protected void |
setSingleThread(java.lang.Thread singleThread)
|
void |
setTeacher(ComparingElement ts)
Sets the Teacher for this NeuralNet object |
void |
singleStepBackward(Pattern error)
Use this method to perform a single step backward. |
void |
singleStepForward(Pattern pattern)
Use this method to perform a single step forward. |
void |
start()
Starts all the Layers' threads, in order to prepare the launch of the neural network in multi-thread mode. |
protected void |
stepBackward(Pattern error)
|
protected void |
stepForward(Pattern pattern)
|
void |
stop()
Terminates the execution of this NeuralNet independently from the threading mode activated. |
protected void |
stopFastRun()
This method serves to stop the network when running in single-thread mode. |
void |
terminate()
Terminates the execution of all the threads of the neural network. |
void |
terminate(boolean notify)
Terminates the execution of all the threads of the neural network. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INPUT_LAYER
public static final int HIDDEN_LAYER
public static final int OUTPUT_LAYER
protected java.util.Vector listeners
protected int patternNumber
Constructor Detail |
---|
public NeuralNet()
Method Detail |
---|
public void start()
start
in interface NeuralLayer
public void join()
Thread.join()
public void stop()
public void terminate(boolean notify)
notify
- if true, the netStopped event is raisedpublic void terminate()
this.terminate(boolean notify)
protected int getNumOfstepCounters()
public Layer getInputLayer()
public Layer findInputLayer()
public Layer getOutputLayer()
public Layer findOutputLayer()
public int getRows()
NeuralLayer
getRows
in interface NeuralLayer
public void setRows(int p1)
NeuralLayer
setRows
in interface NeuralLayer
p1
- The number of the neurons contained in the Layerpublic void addNoise(double p1)
NeuralLayer
addNoise
in interface NeuralLayer
p1
- the noise's amplitude in terms of distance from zero;
e.g.: a value equal 0.3 means a noise from -0.3 to 0.3public void randomize(double amplitude)
public Matrix getBias()
NeuralLayer
getBias
in interface NeuralLayer
public java.util.Vector getAllOutputs()
NeuralLayer
getAllOutputs
in interface NeuralLayer
public java.lang.String getLayerName()
NeuralLayer
getLayerName
in interface NeuralLayer
public void removeOutputSynapse(OutputPatternListener p1)
NeuralLayer
removeOutputSynapse
in interface NeuralLayer
p1
- the output listener to removepublic void setAllInputs(java.util.Vector p1)
NeuralLayer
setAllInputs
in interface NeuralLayer
p1
- The vector containing the list of input synapsespublic void removeAllOutputs()
NeuralLayer
removeAllOutputs
in interface NeuralLayer
public java.util.Vector getAllInputs()
NeuralLayer
getAllInputs
in interface NeuralLayer
public boolean addOutputSynapse(OutputPatternListener p1)
NeuralLayer
addOutputSynapse
in interface NeuralLayer
p1
- The new output synapse
public void setBias(Matrix p1)
NeuralLayer
setBias
in interface NeuralLayer
p1
- The Matrix object containing the biasespublic void removeInputSynapse(InputPatternListener p1)
NeuralLayer
removeInputSynapse
in interface NeuralLayer
p1
- the input listener to removepublic void setLayerName(java.lang.String p1)
NeuralLayer
setLayerName
in interface NeuralLayer
p1
- The namepublic boolean addInputSynapse(InputPatternListener p1)
NeuralLayer
addInputSynapse
in interface NeuralLayer
p1
- The new input synapse
public void setAllOutputs(java.util.Vector p1)
NeuralLayer
setAllOutputs
in interface NeuralLayer
p1
- The vector containing the list of output synapsespublic void setMonitor(Monitor p1)
NeuralLayer
setMonitor
in interface NeuralLayer
p1
- The Monitor to be setpublic Monitor getMonitor()
NeuralLayer
getMonitor
in interface NeuralLayer
public void removeAllInputs()
NeuralLayer
removeAllInputs
in interface NeuralLayer
public NeuralLayer copyInto(NeuralLayer p1)
copyInto
in interface NeuralLayer
p1
- neural.engine.Layer
public void addLayer(Layer layer)
public void addLayer(Layer layer, int tier)
public void removeLayer(Layer layer)
public void resetInput()
public void reset()
public void addNeuralNetListener(NeuralNetListener listener)
public java.util.Vector getListeners()
public void removeNeuralNetListener(NeuralNetListener listener)
public static java.lang.String getVersion()
public static java.lang.Integer getNumericVersion()
public Layer getLayer(java.lang.String layerName)
public java.util.Vector getLayers()
public void setLayers(java.util.Vector newlayers)
public void setLayersList(java.util.List list)
public void setTeacher(ComparingElement ts)
TeachingSynapse
- - the new teacher. It can be null to make unsupervised this neural networkpublic ComparingElement getTeacher()
public void setListeners(java.util.Vector listeners)
listeners
- public void setInputLayer(Layer newLayer)
public void setOutputLayer(Layer newLayer)
public NeuralNetAttributes getDescriptor()
public void setDescriptor(NeuralNetAttributes newdescriptor)
public boolean isRunning()
isRunning
in interface NeuralLayer
public NeuralNet cloneNet()
public void removeAllListeners()
public void setScriptingEnabled(boolean enabled)
enabled
- true to enable the scripting, otherwise falsepublic boolean isScriptingEnabled()
public MacroInterface getMacroPlugin()
public void setMacroPlugin(MacroInterface macroPlugin)
macroPlugin
- New value of property macroPlugin.public java.lang.Object getParam(java.lang.String key)
key
- The searched key
public void setParam(java.lang.String key, java.lang.Object obj)
key
- The key of the paramobj
- The value of the parampublic java.lang.String[] getKeys()
public java.util.TreeSet check()
check
in interface NeuralLayer
NeuralLayer
public void netStarted(NeuralNetEvent e)
netStarted
in interface NeuralNetListener
e
- public void cicleTerminated(NeuralNetEvent e)
cicleTerminated
in interface NeuralNetListener
e
- public void netStopped(NeuralNetEvent e)
netStopped
in interface NeuralNetListener
e
- public void errorChanged(NeuralNetEvent e)
errorChanged
in interface NeuralNetListener
e
- public void netStoppedError(NeuralNetEvent e, java.lang.String error)
netStoppedError
in interface NeuralNetListener
error
- The error message.e
- The event source of this event.public void setOrderedLayers(Layer[] orderedLayers)
orderedLayers
- an array containing the ordered layerspublic Layer[] getOrderedLayers()
public Layer[] calculateOrderedLayers()
public void go(boolean singleThreadMode, boolean sync)
singleThreadMode
- If true, runs the network in single thread modesync
- If true, runs the network in a separated thread and returns immediately.public void go(boolean sync)
sync
- If false, runs the network in a separated thread and returns immediately.public void go()
public void restore(boolean sync)
sync
- If false, runs the network in a separated thread and returns immediately.public void restore()
protected void fastRun()
protected void fastContinue()
protected void fastRun(int firstEpoch, boolean continuation)
firstEpoch
- the epoch from which the network will start.continuation
- if set layers of NN will not be initialized before runpublic int getPatternNumber()
public void singleStepForward(Pattern pattern)
pattern
- The input pattern to use. If null, the input pattern is read from the input synapse connected to the input layer.public void singleStepBackward(Pattern error)
pattern
- The error pattern to backpropagate. If null, the pattern is read from the teacher connected to the output layer.protected void stepForward(Pattern pattern)
protected void stepBackward(Pattern error)
protected void stopFastRun()
protected java.lang.Thread getSingleThread()
protected void setSingleThread(java.lang.Thread singleThread)
public void resetInitialState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |