Mercurial > projects > aid
diff trunk/aid/nn/perceptron.d @ 3:314d68bafeff
Backprop and backprop_test added (no testing).
author | revcompgeek |
---|---|
date | Fri, 11 Apr 2008 18:12:55 -0600 |
parents | 9655c8362b25 |
children | ff92c77006c7 |
line wrap: on
line diff
--- a/trunk/aid/nn/perceptron.d Sat Apr 05 23:41:30 2008 -0600 +++ b/trunk/aid/nn/perceptron.d Fri Apr 11 18:12:55 2008 -0600 @@ -1,38 +1,10 @@ module aid.nn.perceptron; -import std.random; +import aid.nn.outputFunctions; +import aid.misc; import std.math; import std.string; -double rnd(){ // The function that should be included in every math library! - return (cast(double)rand())/uint.max; -} - -class InputException : Exception { - this(char[] message){ - super(message); - } -} - -// The output functions - -alias double function(double) OutputFunction; - -double sign(double y){ - if(y>0) return 1; - return -1; -} - -double sigmoid(double x){ - return 1/(1+exp(-x)); -} - -double tanh(double x){ - return cast(double)tanh(cast(real)x); -} - -// End output functions - class perceptron { private int numInputs; @@ -42,7 +14,7 @@ /** * This is the constructor for loading the neural network from a string. - * + * * Params: * savedString = The string that was output from the save function. * @@ -74,10 +46,10 @@ /** * Evaluates the neural network. - * + * * Params: * inputs = The set of inputs to evaluate. - * + * * Returns: 1 to indicate true, -1 for false */ @@ -117,7 +89,7 @@ /** * Calculates the error based on the sum squared error function. - * + * * Params: * inputs = An array of arrays of all testing inputs. * outputs = An array of all the outputs that the cooresponding inputs should have. @@ -140,3 +112,4 @@ } } +// TODO: Impliment loading and saving of files \ No newline at end of file