So I've finally gotten around to making the artificial intelligence programs I've been talking about for however long it's been. I spent about a good two hours last night working on a simple neural network setup, and evolution algorithm to allow it to learn. I was able to finish them both in only 2 classes, each with less then 100 lines. Knowing that a lot of the processes here are going to be quite taxing, I challenged myself to make them run as memory friendly, and CPU friendly as possible. To achieve this, I make the entire network run solely in arrays. Using only 4 (really long) arrays, more specifically.
Wanting to stress test it, I make a 100 x 100 neuron brain, (plus 99 bias neurons), and ran it 1000 times to find the average time for a single step. I was quite surprised that the entire network, consisting off 10,099 neurons, and 999,900 connections, completed a single step in only a mere 2.7 ms. That's insane. I'm quite happy.
In addition to only using arrays to store all of the neutral network data, I didn't use and taxing functions such as Sigmoid. I used a base 4 polynomial, which was set by the evolutionary algorithm to whatever function is wanted. This means that all of the math used in the network was simply adding and multiplication. Because of the MAD rule in computing, (MAD basically means that multiplying then adding can be preformed in a single CPU cycle.) this was almost no problem at all for the computer. This is well more then enough neurons to complete most tasks that a neural network would need.
In fact, the network could be expanded on even more, if needed. The largest I was able to do before running into memory issues was 300 x 300. At this point, I was already using all of the virtual memory Java had given to me by default. I could've easily allocated more memory, but it was unnecessary. At 300 x 300 neurons, the network completed a single step in about 195\ms.
If you want to see the code for this class, see this link. (Note: By the time you read this, the code may have been expanded on, so it may have a lot more features, be faster, or whatever else I do to it.)
Now, to start out with this project, I need to think of an environment. I was originally going to make a hunt and gather type world, but that wouldn't really put must focus on the types of learning I've really been wanting to dive into. As of now, I'm stumped as for which type of world to make for it.
No comments:
Post a Comment