P. 1
Joone Complete Guide

Joone Complete Guide


|Views: 5,219|Likes:
Published by Chris Nash
Joone (http://www.joone.org/) is a Java framework to build and run AI applications based on neural networks. Joone applications can be built on a local machine, be trained on a distributed environment and run on whatever
Joone (http://www.joone.org/) is a Java framework to build and run AI applications based on neural networks. Joone applications can be built on a local machine, be trained on a distributed environment and run on whatever

More info:

Published by: Chris Nash on Jul 04, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





The Synapse object represents the connection between two layers, permitting
a pattern to be passed from one layer to another.
The Synapse is also the ‘memory’ of a neural network. During the training
process the weighs of the synapse (contained in the Matrix object) are modified
according the implemented learning algorithm.
As described above, a synapse is both the output synapse of a layer and the
input synapse of the next connected layer in the NN. To do this, the synapse
object implements the


and the

OutputPatternListener interfaces.
These interfaces contain respectively the described methods fwGet, revPut,
fwPut and revGet.

The following code describes how they are implemented in the Synapse object:

public synchronized void fwdPut(Pattern pattern) {
if (isEnabled()) {
count = pattern.getCount();
if ((count > ignoreBefore) || (count == -1)) {
while (items > 0) {
try {

} catch (InterruptedException e) {



Joone Core Engine

The Complete Guide

return; }

m_pattern = pattern;
inps = (double[])pattern.getArray();




public synchronized Pattern fwdGet() {
if (!isEnabled())
return null;
while (items == 0) {
try {

} catch (InterruptedException e) {
return null;


return m_pattern;


The Synapse is the shared resource between two Layers that, as already
mentioned, in the multi-thread mode run on two separate threads. To avoid a
layer trying to read the pattern from its input synapse before the other layer
has written it, the shared synapse in synchronized.

Looking at the code, the variable called ‘items’ represents the semaphore of
this synchronization mechanism. After the first Layers calls the fwdPut method,
the items variable is incremented to indicate that the synapse is ‘full’.
Conversely, after the subsequent Layer calls the fwdGet method, this variable
is decremented, indicating that the synapse is ‘empty’.

Both the above methods control the ‘items’ variable when they are invoked:

1.If a layer tries to call the fwPut method when items is greater then zero,
its thread falls in the wait state, because the synapse is already full.
2.In the fwGet method, if a Layer tries to get a pattern when items is equal
to zero (meaning that the synapse does not contain a pattern) then its
corresponding thread falls in the wait state.

The notifyAll call at the end of the two methods permits the ‘awakening’ of
the other waiting layer, signalling that the synapse is ready to be read or
written. After the notifyAll, at the end of the method, the running thread
releases the owned object permitting another waiting thread to take ownership.
Note that although all waiting threads are notified by notifyAll, only one will
acquire a lock and the other threads will return to a wait state.
The synchronizing mechanism is the same in the corresponding revGet and
revPut methods for the training phase of the neural network.



Joone Core Engine

The Complete Guide

The fwPut method calls the abstract forward method (at the same time as the
revPut calls the abstract backward method) to permit to the inherited classes
to implement respectively the recall and the learning formulas, as already
described for the Layer object (according to the Template design pattern).
By writing the appropriate code in these two methods, the engine can be
extended with new synapses and layers implementing whatever learning
algorithm and architecture is required.

Starting from Joone v.2.0, in the new single-thread engine the mechanism is
very similar, but in this case the xxxGet/Put methods are invoked by a single
thread (instantiated by the NeuralNet object), so there isn't any conflict
between concurrent threads, resulting in an improvement of the performances
of about 50%.



Joone Core Engine

The Complete Guide

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->