modify COMPARE_N in tool, modify attribute of vehicle by using tensor

This commit is contained in:
2024-06-13 23:35:25 +02:00
parent 13f91583bb
commit 9927d6642c
12 changed files with 217 additions and 56 deletions
+13
View File
@@ -747,6 +747,19 @@ size_t learning_online2_neurons_##type(neurons_##type *base, data_set_##type *da
return nbreps;\
}\
\
void calculate_output_by_network_neurons_##type(neurons_##type *base, tensor_##type *input, tensor_##type **output_link){\
for(size_t i=0; i<(input->dim)->rank; ++i) (base->output)->x[i]=input->x[i];\
neurons_##type * tmp=base->next_layer;\
while(tmp){\
calc_out_neurons_##type(tmp);\
if(tmp->next_layer==NULL){\
/*print_tensor_msg_##type(tmp->output,"retult");*/\
*output_link = tmp->output;\
}\
tmp = tmp->next_layer;\
}\
\
}\
void print_predict_by_network_neurons_##type(neurons_##type *base, tensor_##type *input){\
for(size_t i=0; i<(input->dim)->rank; ++i) (base->output)->x[i]=input->x[i];\
neurons_##type * tmp=base->next_layer;\
+1 -1
View File
@@ -106,7 +106,7 @@ void print_data_set_msg_##type(data_set_##type *ds, char *msg);\
\
size_t learning_online_neurons_##type(neurons_##type *base, data_set_##type *dataset, bool (*condition)(type, size_t));\
size_t learning_online2_neurons_##type(neurons_##type *base, data_set_##type *dataset, bool (*condition)(type, size_t));\
\
void calculate_output_by_network_neurons_##type(neurons_##type *base, tensor_##type *input, tensor_##type **output_link);\
void print_predict_by_network_neurons_##type(neurons_##type *base, tensor_##type *input);\
void print_predict_by_network_with_error_neurons_##type(neurons_##type *base, tensor_##type *input, tensor_##type *target);\
\
+21 -3
View File
@@ -21,6 +21,7 @@
#define VALGRIND_ 1
float L(float t, float o){
return (o - t) * (o - t)/2;
}
@@ -356,13 +357,30 @@ TEST(copy_weight_in_neurons){
size_t reps = learning_online2_neurons_TYPE_FLOAT(bn,ds,cond);
setup_all_layers_functions_TYPE_FLOAT(cpyn,
tensorContractnProdThread_TYPE_FLOAT,
tensorProdThread_TYPE_FLOAT,
DL,
L,
f,
df);
setup_all_layers_params_TYPE_FLOAT(cpyn, 5, 1 , 0.1);
copy_weight_in_neurons_TYPE_FLOAT(cpyn, bn);
char msg[256];
tensor_TYPE_FLOAT * linked_tens = NULL;
for(size_t i=0; i<ds->size; ++i){
print_predict_by_network_with_error_neurons_TYPE_FLOAT(bn,ds->input[i],ds->target[i]);
print_predict_by_network_with_error_neurons_TYPE_FLOAT(cpyn,ds->input[i],ds->target[i]);
// print_predict_by_network_with_error_neurons_TYPE_FLOAT(bn,ds->input[i],ds->target[i]);
// print_predict_by_network_with_error_neurons_TYPE_FLOAT(cpyn,ds->input[i],ds->target[i]);
calculate_output_by_network_neurons_TYPE_FLOAT(bn,ds->input[i],&linked_tens);
sprintf(msg," output base %ld ",i);
print_tensor_msg_TYPE_FLOAT(linked_tens,msg);
calculate_output_by_network_neurons_TYPE_FLOAT(cpyn,ds->input[i],&linked_tens);
sprintf(msg," output copy %ld ",i);
print_tensor_msg_TYPE_FLOAT(linked_tens,msg);
}