9 sum +=
exp(-activations[i]);
12 net_outputs[i] =
exp(-activations[i])/
sum;
18 for( i = 0; i < size; i++) {
19 dactivations[i] = activations[i]*(1.0-activations[i]);
20 activations[i] = 1.0/(1.0+
exp(-activations[i]));
25 TYPE activations[nodes_per_layer],
28 for( i = 0; i < size; i++){
29 activations[i] = activations[i] + biases[i];
35 TYPE activations[nodes_per_layer],
39 activations[j] = (
TYPE)0.0;
41 activations[j] += weights[j*input_dimension + i] * input_sample[i];
48 TYPE weights[nodes_per_layer*nodes_per_layer],
49 TYPE activations[nodes_per_layer],
50 TYPE input_activations[nodes_per_layer]){
53 activations[i] = (
TYPE)0.0;
55 activations[i] += weights[i*nodes_per_layer + j] * input_activations[j];
63 TYPE activations[possible_outputs],
67 activations[j] = (
TYPE)0.0;
69 activations[j] += weights[j*nodes_per_layer + i] * input_activations[i];
76 TYPE solutions[possible_outputs],
77 TYPE output_difference[possible_outputs],
78 TYPE dactivations[possible_outputs]) {
81 output_difference[i] = (((net_outputs[i]) - solutions[i]) * -1.0) * dactivations[i];
86 TYPE output_difference[possible_outputs],
91 delta_weights3[i*possible_outputs + j] = last_activations[i] * output_difference[j];
97 TYPE output_differences[possible_outputs],
99 TYPE dactivations[nodes_per_layer]) {
102 oracle_activations[i] = (
TYPE)0.0;
104 oracle_activations[i] += output_differences[j] *
weights3[i*possible_outputs + j];
106 oracle_activations[i] = oracle_activations[i] * dactivations[i];
111 TYPE output_difference[nodes_per_layer],
112 TYPE last_activations[nodes_per_layer]) {
116 delta_weights2[i*nodes_per_layer + j] = last_activations[i] * output_difference[j];
122 TYPE output_differences[nodes_per_layer],
123 TYPE oracle_activations[nodes_per_layer],
124 TYPE dactivations[nodes_per_layer]) {
127 oracle_activations[i] = (
TYPE)0.0;
129 oracle_activations[i] += output_differences[j] *
weights2[i*nodes_per_layer + j];
131 oracle_activations[i] = oracle_activations[i] * dactivations[i];
136 TYPE output_difference[nodes_per_layer],
141 delta_weights1[i*nodes_per_layer + j] = last_activations[i] * output_difference[j];
150 TYPE d_weights2[nodes_per_layer*nodes_per_layer],
151 TYPE d_weights3[nodes_per_layer*possible_outputs],
155 TYPE d_biases1[nodes_per_layer],
156 TYPE d_biases2[nodes_per_layer],
157 TYPE d_biases3[possible_outputs]) {
159 double norm, bias_norm;
175 bias_norm = sqrt(bias_norm);
187 bias_norm = (double)0.0;
201 bias_norm = sqrt(bias_norm);
213 bias_norm = (double)0.0;
227 bias_norm = sqrt(bias_norm);
266 activations1[j] = (
TYPE)0.0;
267 activations2[j] = (
TYPE)0.0;
268 if(j<possible_outputs){
269 activations3[j] = (
TYPE)0.0;
273 RELU(activations1, dactivations1, nodes_per_layer);
275 RELU(activations2, dactivations2, nodes_per_layer);
277 RELU(activations3, dactivations3, possible_outputs);
278 soft_max(net_outputs, activations3);
void matrix_vector_product_with_bias_output_layer(TYPE biases[possible_outputs], TYPE weights[nodes_per_layer *possible_outputs], TYPE activations[possible_outputs], TYPE input_activations[nodes_per_layer])
void take_difference(TYPE net_outputs[possible_outputs], TYPE solutions[possible_outputs], TYPE output_difference[possible_outputs], TYPE dactivations[possible_outputs])
void add_bias_to_activations(TYPE biases[nodes_per_layer], TYPE activations[nodes_per_layer], int size)
TYPE weights1[input_dimension *nodes_per_layer]
void RELU(TYPE activations[nodes_per_layer], TYPE dactivations[nodes_per_layer], int size)
void get_delta_matrix_weights2(TYPE delta_weights2[nodes_per_layer *nodes_per_layer], TYPE output_difference[nodes_per_layer], TYPE last_activations[nodes_per_layer])
void get_delta_matrix_weights1(TYPE delta_weights1[input_dimension *nodes_per_layer], TYPE output_difference[nodes_per_layer], TYPE last_activations[input_dimension])
TYPE biases3[possible_outputs]
void backprop(TYPE weights1[input_dimension *nodes_per_layer], TYPE weights2[nodes_per_layer *nodes_per_layer], TYPE weights3[nodes_per_layer *possible_outputs], TYPE biases1[nodes_per_layer], TYPE biases2[nodes_per_layer], TYPE biases3[possible_outputs], TYPE training_data[training_sets *input_dimension], TYPE training_targets[training_sets *possible_outputs])
void get_oracle_activations1(TYPE weights2[nodes_per_layer *nodes_per_layer], TYPE output_differences[nodes_per_layer], TYPE oracle_activations[nodes_per_layer], TYPE dactivations[nodes_per_layer])
TYPE biases2[nodes_per_layer]
TYPE training_targets[training_sets *possible_outputs]
TYPE weights2[nodes_per_layer *nodes_per_layer]
TYPE biases1[nodes_per_layer]
void soft_max(TYPE net_outputs[possible_outputs], TYPE activations[possible_outputs])
TYPE weights3[nodes_per_layer *possible_outputs]
void get_oracle_activations2(TYPE weights3[nodes_per_layer *possible_outputs], TYPE output_differences[possible_outputs], TYPE oracle_activations[nodes_per_layer], TYPE dactivations[nodes_per_layer])
void update_weights(TYPE weights1[input_dimension *nodes_per_layer], TYPE weights2[nodes_per_layer *nodes_per_layer], TYPE weights3[nodes_per_layer *possible_outputs], TYPE d_weights1[input_dimension *nodes_per_layer], TYPE d_weights2[nodes_per_layer *nodes_per_layer], TYPE d_weights3[nodes_per_layer *possible_outputs], TYPE biases1[nodes_per_layer], TYPE biases2[nodes_per_layer], TYPE biases3[possible_outputs], TYPE d_biases1[nodes_per_layer], TYPE d_biases2[nodes_per_layer], TYPE d_biases3[possible_outputs])
TYPE training_data[training_sets *input_dimension]
void matrix_vector_product_with_bias_input_layer(TYPE biases[nodes_per_layer], TYPE weights[input_dimension *nodes_per_layer], TYPE activations[nodes_per_layer], TYPE input_sample[input_dimension])
void matrix_vector_product_with_bias_second_layer(TYPE biases[nodes_per_layer], TYPE weights[nodes_per_layer *nodes_per_layer], TYPE activations[nodes_per_layer], TYPE input_activations[nodes_per_layer])
void get_delta_matrix_weights3(TYPE delta_weights3[nodes_per_layer *possible_outputs], TYPE output_difference[possible_outputs], TYPE last_activations[nodes_per_layer])