| 15 | { |
| 16 | |
| 17 | class mlp_kernel_1 : noncopyable |
| 18 | { |
| 19 | /*! |
| 20 | INITIAL VALUE |
| 21 | The network is initially initialized with random weights |
| 22 | |
| 23 | CONVENTION |
| 24 | - input_layer_nodes() == input_nodes |
| 25 | - first_hidden_layer_nodes() == first_hidden_nodes |
| 26 | - second_hidden_layer_nodes() == second_hidden_nodes |
| 27 | - output_layer_nodes() == output_nodes |
| 28 | - get_alpha == alpha |
| 29 | - get_momentum() == momentum |
| 30 | |
| 31 | |
| 32 | - if (second_hidden_nodes == 0) then |
| 33 | - for all i and j: |
| 34 | - w1(i,j) == the weight on the link from node i in the first hidden layer |
| 35 | to input node j |
| 36 | - w3(i,j) == the weight on the link from node i in the output layer |
| 37 | to first hidden layer node j |
| 38 | - for all i and j: |
| 39 | - w1m == the momentum terms for w1 from the previous update |
| 40 | - w3m == the momentum terms for w3 from the previous update |
| 41 | - else |
| 42 | - for all i and j: |
| 43 | - w1(i,j) == the weight on the link from node i in the first hidden layer |
| 44 | to input node j |
| 45 | - w2(i,j) == the weight on the link from node i in the second hidden layer |
| 46 | to first hidden layer node j |
| 47 | - w3(i,j) == the weight on the link from node i in the output layer |
| 48 | to second hidden layer node j |
| 49 | - for all i and j: |
| 50 | - w1m == the momentum terms for w1 from the previous update |
| 51 | - w2m == the momentum terms for w2 from the previous update |
| 52 | - w3m == the momentum terms for w3 from the previous update |
| 53 | !*/ |
| 54 | |
| 55 | public: |
| 56 | |
| 57 | mlp_kernel_1 ( |
| 58 | long nodes_in_input_layer, |
| 59 | long nodes_in_first_hidden_layer, |
| 60 | long nodes_in_second_hidden_layer = 0, |
| 61 | long nodes_in_output_layer = 1, |
| 62 | double alpha_ = 0.1, |
| 63 | double momentum_ = 0.8 |
| 64 | ) : |
| 65 | input_nodes(nodes_in_input_layer), |
| 66 | first_hidden_nodes(nodes_in_first_hidden_layer), |
| 67 | second_hidden_nodes(nodes_in_second_hidden_layer), |
| 68 | output_nodes(nodes_in_output_layer), |
| 69 | alpha(alpha_), |
| 70 | momentum(momentum_) |
| 71 | { |
| 72 | |
| 73 | // seed the random number generator |
| 74 | std::ostringstream sout; |