In the interest of trying to lead my life according to my recent minor obession: John Maeda’s Laws of Simplicity, I have decided to start off the Spring semester with a little bit of law 1: Reduce.
It’s been a while since I published a new work. But there’s nothing like a deadline. A year ago, I installed three of my works at the Jepson Center for the Arts in Savannah, GA. Since the installation was set to run for three years, it seemed like a nice, altogether reasonable thing to say “Well, how about in a year, I come back and swap out one of my old pieces for a new one?” A year quickly fills up with teaching, working on a book, and living la vida loca. Nevertheless, here I am, a week from heading back down to Savannah and spending all day programming again.
When I first developed the two generative pieces, swarm and mosaic, I always imagined them part of a series of three. I was working on my ITP thesis, an exploration of generative systems in the production of real-time non-photorealistic imagery. Flocking. Cellular Automata. The usual. Having only one semester, I never made it to adopting their formulaic sibling, Fractals (I think I might have to name a pet Fractals some day, kind of like Freckles, only nerdier.) Looking at how L-Systems work (which we do in my nature of code class), the idea was to create a generative garden of abstract and algorithmic trees, shrubs, and flowers, growing on and about the screen, creating a nice little digital painting of the viewer.
Some screenshots and a video (first one is me, second one is my dog, Petey “Fractals” Caloyeras):
I’m not entirely satisfied with the result, as of yet. It’s nice to look at, but it’s just the swarm effect duplicated, only instead of smearing pixels with in a flocking pattern, they are smeared in a recursive tree pattern. I like to keep things simple, but perhaps augmenting the interaction in such a way that, at the very least, the viewer has a sense of “planting seeds” might improve the experience. I also intend to try some more sophisticated plant patterns, but with only one day of experimenting, keeping it simple for now. . .
Ok, so I will probably go back to using the video comments plug-in for posting video, but how could I live one more day without at least publishing one video to YouTube??
I’ve updated the Processing moviemaker library. Implemented more codecs and I think I fixed the Intel Mac bugs (but no way to tell since I don’t have one.) Hopefully nothing else broke in the process. Anyone reading this on an intel mac or windows machine, please test and let me know, thanks! Oh, and documentation coming soon!
A first pass at my Neural Networks in processing tutorial is ready for public consumption. So, before you go and consume a turkey, consume this link. And let me know if it makes any sense at all. . .? The examples are still trivial — Linear classification, Solving XOR — but I hope to develop some more advanced pattern recognition examples soon!
Is it a penguin? A tooth? A surfer from the future? Whatever it is, this announcement sure does make me happy. Read more about it at Create Digital Motion, one of my new favorite blogs!
So after a fierce battle with my own neurons, I am ready to release part II of my Processing series: “Neural Network! Huah! What is it good for? (Sing it again, now.)”
This example implements a multi-layered neural network that learns via “back propogation.” It’s specifically trained to solve XOR. In other words, there are two inputs and the desired result is input1 XOR input2.
0,1 –> 1
1,0 –> 1
0,0 –> 0
1,1 –> 0
The structure looks something like this:
However, I think there might be a flaw in my back propogation learning algorithm. For whatever reason, with the above neural structure, I can only successfully train my network (starting with random connection weights between -1 and 1) approximately 60% of the time. For the other 40%, the network gets stuck and can’t find the proper solution. If I add two more neurons to the hidden layer, like so. . .
. . . it trains flawlessly, finding a reasonable solution space after a few thousand training iterations 100% of the time (or at least as far as I can reasonably test.) What am I missing?
Anyway, a more involved tutorial about the theory, concepts, algorithms, and code behind neural networks is forthcoming. . . at some point. . . after I invent that machine that makes time that is . .
If you are downloading the source, note that the code for the nn.jar package is contained in /xor/code/src/nn. Because I’m using a large number of classes in the design of the network, I didn’t want to restrict myself to Processing tabs. Update (2/08/10): New download link: http://www.shiffman.net/teaching/nature/nn/
In this example, the perceptron is trained via an array of known point objects (with known answers), and the resulting “guess” line is displayed in real-time. I made the learning constant rather low so that one can see the slow progression of changing weights. I’ve been spending some quality time with Artifical Intelligence, by George Luger. It’s a wonderful book, and even better, it’s free for download online!
All the code is in the link, but here’s a quick peek at the meat of the matter: a function inside the Perceptron class that adjusts weights according to 3 input values and their corresponding “known” output. (Note if the perceptron’s guess output produces the desired result, the weights are not changed.)
A more involved write-up will arrive online at some point. . .
// Function to train the Perceptron// Weights are adjusted based on "desired" answervoid train(float[] vals, int desired){// Sum all the weightsfloat sum =0;for(int i =0; i < weights.length; i++){
sum += vals[i]*weights[i];}// The result is the sign of the sumint result =1;// Start with 1if(sum <0) result =-1;// If less than zero, change to -1// Compute factor to change weight// (DESIRED - RESULT): note this can only be 0, -2, or 2// Multiply by learning constantfloat weightChange = c*(desired - result);// Adjust weights based on weightChange * inputfor(int i =0; i < weights.length; i++){
weights[i]+= weightChange * vals[i];}}
An article about ITP was published yesterday in the New York Sun. Now, I’m no fan of this newspaper (see their editorials, which I couldn’t bear to read), but they do have excellent arts coverage, and they did capture ITP quite well. But did I really say this?
“Ultimately, it’s about the human connection — what technology can do for us.”
Thanks to an idea from students in my icm class (see Catherine’s “greedy game-animated sprite”), I developed a Processing library that grabs values from Apple’s sudden motion sensor. The library is a JNI implementation of Unimotion by Lincoln Ramsay. It hasn’t been tested on an intel mac, so let me know if it works for people!