Trying to fix nan output of RL by using relu with upperbound

This commit is contained in:
2024-07-16 12:13:05 +02:00
parent 0c9813beca
commit aac7434346
13 changed files with 405 additions and 75 deletions
+1
View File
@@ -768,6 +768,7 @@ neurons_##type * calculate_output_by_network_neurons_##type(neurons_##type *base
if(tmp->next_layer==NULL){\
/*print_tensor_msg_##type(tmp->output,"retult");*/\
*output_link = tmp->output;\
\
return tmp;\
}\
tmp = tmp->next_layer;\
+74 -2
View File
@@ -18,6 +18,7 @@
//#include "permutation_t/permutation_t.h"
#include "neuron_t/neuron_t.h"
#include "neuron_t/nneuron_t_file.h"
#define VALGRIND_ 1
@@ -135,7 +136,6 @@ TEST(learning_first){
*/
}
free_data_set_TYPE_FLOAT(ds);
free_neurons_TYPE_FLOAT(bn);
@@ -145,7 +145,7 @@ TEST(learning_first){
TEST(learning_second){
TEST(learning_second_PRINT){
bool rec_randomizeInitWeight = randomizeInitWeight;
randomizeInitWeight =false;
@@ -184,6 +184,9 @@ TEST(learning_second){
}
PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, bn, input, " bn input");
PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, bn, output, " bn output");
PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(TYPE_FLOAT, bn, bias, " bn bias");
free_data_set_TYPE_FLOAT(ds);
free_neurons_TYPE_FLOAT(bn);
@@ -382,6 +385,8 @@ TEST(copy_weight_in_neurons){
sprintf(msg," output copy %ld ",i);
print_tensor_msg_TYPE_FLOAT(linked_tens,msg);
}
EXPORT_TO_FILE_TENSOR_ATTRIBUTE_IN_NNEURONS(TYPE_FLOAT, bn, weight_in, ".ff_bn_weight_in.txt")
@@ -395,6 +400,73 @@ TEST(copy_weight_in_neurons){
TEST(Extract_weight_in_neurons){
bool rec_randomizeInitWeight = randomizeInitWeight;
randomizeInitWeight =false;
data_set_TYPE_FLOAT *ds= fill_data_set_from_file_TYPE_FLOAT("xor.txt",1);
// print_data_set_msg_TYPE_FLOAT(ds,"data");
config_layers *pconf = create_config_layers_from_OneD(3,(size_t[]){2,4,1}); /* 2 input , 1 target; 1 hidden layer with 5 neurons */
neurons_TYPE_FLOAT *bn=NULL, *tmp ;
neurons_TYPE_FLOAT *cpyn=NULL;
//setup_networks_alloutputs_config_GLOBAL_rdm01_TYPE_FLOAT(setup_networks_alloutputs_config_TYPE_FLOAT(&bn,pconf);bn,pconf);
setup_networks_alloutputs_config_TYPE_FLOAT(&bn,pconf,false,0,1,5000);
setup_networks_alloutputs_config_TYPE_FLOAT(&cpyn, pconf,false,0,1,5000);
setup_all_layers_functions_TYPE_FLOAT(bn,
tensorContractnProdThread_TYPE_FLOAT,
tensorProdThread_TYPE_FLOAT,
DL,
L,
f,
df);
setup_all_layers_params_TYPE_FLOAT(bn, 5, 1 , 0.1);
size_t reps = learning_online2_neurons_TYPE_FLOAT(bn,ds,cond);
EXPORT_TO_FILE_TENSOR_ATTRIBUTE_IN_NNEURONS(TYPE_FLOAT, bn, weight_in, ".ff_bn_weight_in__toExtract.txt")
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);
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, cpyn, weight_in, ".ff_bn_weight_in__toExtract.txt")
// 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]);
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);
}
EXPORT_TO_FILE_TENSOR_ATTRIBUTE_IN_NNEURONS(TYPE_FLOAT, cpyn, weight_in, ".ff_bn_weight_in__exportedCPYfromExtract.txt")
free_data_set_TYPE_FLOAT(ds);
free_neurons_TYPE_FLOAT(bn);
free_neurons_TYPE_FLOAT(cpyn);
LOG("reps = %ld\n",reps);
randomizeInitWeight = rec_randomizeInitWeight;
}