|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Neural Net
I had seen a while ago some people asking about Neural Nets to control robots. I have decided to write a small library. It has basic support for a multi-layered neural network, but one should only need a single perceptron for many mechanical works. Here is the link:
https://www.dropbox.com/s/6dmlzhl8yp...twork.jar?dl=0 Neural Network is a very, very broad term. Saying you want to build a neural net is like saying you want to build a vehicle, or a robot. It's very... generic. As a result, there are many different specializations. The one I present is intended for robots. At least, the first layer is. A Neural Network typically has a collection of neurons. Each neuron receives a sum of values coming from other neurons and outputs some answer that is either modified, conditional or both. This one in particular has its neurons organized in layers and has options for sending a signal top-down based on modification, conditions or both. Those are the ActivationFunctions you can choose from. Sigmoid will give a value from -1 to +1, ideal for motor control. You set up a brain in this library by calling the constructor and for the 'shape' argument, pass in something like this: Code:
new int[]{x,y,z}
When the input goes down this network, the input is copied for each neuron in the layer beneath and each is multiplied by a unique weight between those two individual neurons. The output layer, of course, has no interconnected neurons so does not do that. Instead, each output neuron holds onto a bias value that gets added to its value before going through the activation function. What makes this network special is its avoidance to over-compensating. When the network is trained, it pays less attention to the error value the closer its previous output was to 100% (1.0), so long as the error is in the same direction as the previous output. In other words, there is not reason to increase weights or biases in an attempt to get a better outcome if the previous outcome was as good as it's going to get. That would only build up weights and biases that would take time to revert from when needed. For motor control, I recommend a single neuron in a single layer {1}. Give it a desired speed normalized to -1 thru +1 and grade it on that (its error should be the normalized desired speed - the normalized actual speed). Note: If using this to control position, I recommend sending the distance thru a sigmoid function which will give you values between -1 and +1 and feeding that as the desired speed. You may have to adjust the learning rate in the ctor and make it a small fraction depending on your machine. Also note this works in simulations but has yet to be tested. Last edited by Altainia : 12-03-2015 at 11:20. Reason: Details about the neural net usage |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|