Differences between revisions 38 and 39
Revision 38 as of 2009-03-16 10:30:33
Size: 6283
Editor: JunHu
Comment:
Revision 39 as of 2009-03-16 10:32:02
Size: 6297
Editor: JunHu
Comment:
Deletions are marked like this. Additions are marked like this.
Line 82: Line 82:
#!java #!java numbering=off

g=max(intelligence)

Philip Ross, Jun Hu and Rene Ahn

March 2009

  • /!\ In this "g1=max(intelligence)" workshop we are going to use PC's and Microsoft Windows. If you happen to have a Mac, no problem --- things mentioned in this workshop should work on Mac too. But please find a PC for this workshop because we are not going to deal with platform differences.

1. Workshop material

1.1. Reading

2. Software Installation & Configuration

2.1. Max

Follow the installation instructions came with the software.

When later we try to load Java externals, Max might complain about QuickTime not being installed. So if you don't hate Apple that much, install QuickTime.

2.2. JRE or JDK

To make use of Max quickie (an integrated Java editing and compiling tool within Max), you have to install JDK for its Java compiler. Since in this workshop we are going to use Eclipse for programming Java, JDK is not necessary.

No matter which one to be installed, run the installer and simply follow the instructions.

2.3. Eclipse

To synchronize what we are going to point to and what we are talking about, please install Eclipse and JOONE in C:\Programs. ( /!\ Note, not C:\Program Files --- it has a good reason to do so.)

Extract the downloaded ZIP file to C:\Programs so that eclipse.exe is in C:\Programs\eclipse. Create a shortcut to C:\Programs\eclipse\eclipse.exe on your desktop: Go to C:\Programs\eclipse, right click on eclipse.exe, select Send to and then Desktop(create shortcut).

2.4. JOONE

Download the GUI editor.

If you are using Windows XP, download the version for Windows (Without JVM).

  • Run the installer. When asked by about where would you like to install, answer "C:\Programs\joone". When asked about where would you like to create links, select Other, and choose your Desktop. If you see an error message about available disk space, possibly because you have too much of space left on you C: disk and the installer could not understand the big number of bytes. Ignore the error message unless you are really running out of disk space.

If you are using Windows Vista or Mac, download the version for All Platfs (Without JVM).

  • Extract the downloaded Zip file to C:\Programs so that RunEditor.bat is in C:\Programs\joone. Create a shortcut to RunEditor.bat on your desktop.

After installed Eclipse and JOONE, check again to see whether they are at right places:

EclipseJOONE.png

2.5. JOONE engine for Max

To be able to use Java externals with JOONE engine in Max, JOONE engine must be visible to Max. The simple way to enable it is to copy the JOONE engine

C:\Programs\joone\lib\joone-engine.jar

and put it into Max's Java library directory:

C:\Program Files\Cycling '74\Max 5.0\Cycling '74\java\lib

2.6. Setup Eclipse

In order to communicate with the Max patcher and the JOONE engine, your eclipse project must include both the max.jar library and the joone-engine.jar in its build path:

EclipseBuildPath.png

3. Simple Example: XOR

Follow the GUI example from JOONE website, build and train the neural network to solve the XOR problem. Export the network and load it in your Java program. Try to use the Java program in Max.

The complete source code, sample data and the Max patcher can be downloaded xor.zip

Take a deep breath, here are some beautiful parts from xor.zip:

3.1. The Max patcher

xorpatcher.png

3.2. The Java external

   1 import org.joone.engine.*;
   2 import org.joone.net.*;
   3 import com.cycling74.max.*;
   4 
   5 public class XorNet extends MaxObject {
   6 
   7   NeuralNet nnet = null;
   8   
   9   String snet = "C:/Users/jhu/Documents/Development/workspace/XOR/XOR.snet";
  10 
  11   DirectSynapse memInp = null;
  12   DirectSynapse memOut = null;
  13   
  14   public float inlet_left = 0;
  15   public float inlet_right = 0;
  16 
  17   public XorNet() {
  18     declareInlets(new int[]{DataTypes.FLOAT, DataTypes.FLOAT});
  19     declareOutlets(new int[]{DataTypes.FLOAT});
  20     initNet();
  21   }
  22   
  23   private void initNet(){
  24     NeuralNetLoader netLoader = new NeuralNetLoader(snet);
  25     nnet = netLoader.getNeuralNet();
  26 
  27     Layer input = nnet.getInputLayer();
  28     input.removeAllInputs();
  29     memInp = new DirectSynapse();
  30     input.addInputSynapse(memInp);
  31 
  32     Layer output = nnet.getOutputLayer();
  33     output.removeAllOutputs();
  34     memOut = new DirectSynapse();
  35     output.addOutputSynapse(memOut);
  36 
  37     nnet.getMonitor().setLearning(false);
  38 
  39     nnet.start();
  40   }
  41   
  42   public void inlet(float f){
  43     int inlet_no = getInlet();
  44     if(inlet_no == 0) 
  45       inlet_left = f;
  46     else
  47       inlet_right = f;
  48   }
  49   
  50   public void bang(){
  51     Pattern iPattern = new Pattern(new double[]{inlet_left, inlet_right});
  52     memInp.fwdPut(iPattern);
  53     Pattern oPattern = memOut.fwdGet();
  54     outlet(0, oPattern.getArray()[0]);
  55   }
  56 }
  1. genius, or goal, or glad, or glory, but definitely not garbage (1)

JunHu: MaxJavaArduino (last edited 2011-08-30 18:14:49 by dyn-176109)