tags:

views:

147

answers:

4

I am trying to implement a neural network in java (small one) and I'm using back propogation for the learning algorithm. This requires to find general derivatives. How do I find general derivatives in java?

+1  A: 

Depends on whether you have continuous or discrete data. I'm guessing that you have discrete data, since we're talking about neural nets.

Finite differences are one way to approximate derivatives. Another approach might be to do a fit of some kind and differentiate the fitting function, assuming that it's a well-known function with an easy-to-calculate derivative (e.g., polynomials).

How many independent variables for your data? Functions of one variable are easy; two or more are harder because you need partial derivatives.

duffymo
A: 

I'm pretty certain java does not have built in library for calculus functionality. However, it could range anywhere from trivial to quite challenging to implement differentiation by yourself.

If you already have the ability to store and analyze functions, then getting derivatives is as simple as programming the (quite limited) number of differentiation rules.

However if you are looking at differentiation based on DATAsets (not abstract functions), then you can use various approximation techniques, such as simpsons rule.

Razor Storm
+2  A: 

Try Helmut Dersch's Jasymca 2 http://webuser.hs-furtwangen.de/~dersch/jasymca2/. It's a Java API providing GNU Octave/Matlab-like capabilities. It includes symbolic math.

Jasymca has been recently worked on. The documentation is from March 2009 and it requires Java 1.5+.

CAVEAT: Jasymca is GPL so consult a lawyer before using it in a commercial product.

Alain O'Dea
+1  A: 

OKay, if you are doing neural networks most likely you will NOT need to take just a general derivative of some arbitrary function. Which is what you would need a general Calculus library for. Backprop requires you to use the derivative of your activation function. USUALLY, your activation function is going to be the sigmoid function, or the hyperbolic tan function. Both of which you can just get the derivative of from Wikipedia and simply provide that function to your neural network training. You do not need to actually solve the derivative each time.

There are other common activation functions, but there are really only a handful that are actually used. Just look up the derivative and make use of which one you want. Most neural network frameworks just build the regular activation function and derivative into some sort of a baseclass you use. Here are some of the most common ones:

http://www.heatonresearch.com/online/programming-neural-networks-encog-java/chapter-3/page2.html

JeffHeaton