annotate trunk/aid/misc.d @ 5:810d58835f86

Added momentum and stochastic training to backprop.
author revcompgeek
date Tue, 15 Apr 2008 14:39:49 -0600
parents 314d68bafeff
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
1 module aid.misc;
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
2
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
3 import std.random;
5
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
4 import std.stdio;
3
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
5
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
6 class InputException : Exception {
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
7 this(char[] message){
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
8 super(message);
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
9 }
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
10 }
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
11
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
12 double rnd(){ // The function that should be included in every math library!
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
13 return (cast(double)rand())/uint.max;
5
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
14 }
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
15
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
16 void printArray(double[] array){
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
17 writef("[");
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
18 for(int i=0; i<array.length-1; i++){
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
19 writef("%f, ",array[i]);
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
20 }
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
21 writefln("%f]",array[$-1]);
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
22 }
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
23
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
24 void printArray(double[][] array){
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
25 writef("[");
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
26 for(int i=0; i<array.length; i++){
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
27 printArray(array[i]);
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
28 }
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
29 writefln("]");
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
30 }
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
31
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
32 void printArray(double[][][] array){
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
33 writef("[");
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
34 for(int i=0; i<array.length; i++){
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
35 printArray(array[i]);
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
36 }
810d58835f86 Added momentum and stochastic training to backprop.
revcompgeek
parents: 3
diff changeset
37 writefln("]");
3
314d68bafeff Backprop and backprop_test added (no testing).
revcompgeek
parents:
diff changeset
38 }