wip: set_neurons : transfert training
This commit is contained in:
@@ -23,8 +23,9 @@ YLISTDIR=$(ROOTPROJECTDIR)/list_t
|
||||
YWORKDIR=$(ROOTPROJECTDIR)/y_worker_t
|
||||
YJSONDIR=$(ROOTPROJECTDIR)/yjson_t
|
||||
YSOCKET_DIR=$(ROOTPROJECTDIR)/y_socket_t
|
||||
#DIMENSIONDIR=$(ROOTPROJECTDIR)/dimension_t
|
||||
|
||||
INCLUDE_SOCKET=-I$(YSOCKET_DIR)/include -I$(YLISTDIR)/src -I$(YWORKDIR)/include -I$(YJSONDIR)/src -I$(YSOCKET_DIR)/include
|
||||
INCLUDE_SOCKET=-I$(YSOCKET_DIR)/include -I$(YLISTDIR)/src -I$(YWORKDIR)/include -I$(YJSONDIR)/src -I$(YSOCKET_DIR)/include #-I$(DIMENSIONDIR)/src
|
||||
|
||||
LIB_SOCKET=$(YSOCKET_DIR)/libysocket.so
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "fmock/fmock.h"
|
||||
|
||||
#include "neuron_t/neuron_t.h"
|
||||
//#include "dimension_t/dimension_t.h"
|
||||
|
||||
#include "vehicle.h"
|
||||
#include "learn_to_drive.h"
|
||||
@@ -772,8 +773,240 @@ struct status_qlearning *qlstatus = create_status_qlearning ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST(extract_with_pconf){
|
||||
size_t nb_block = 7;
|
||||
size_t dim= 2;
|
||||
struct blocks * path = create_blocks(nb_block, dim);
|
||||
|
||||
LOG("debug: f_name = %s\n", __func__);
|
||||
|
||||
#if 1
|
||||
TEST(_first_learn_vehicle_50__11){
|
||||
|
||||
copy_coordinate(path->lower_bound_block[0], (float[]){0,0});
|
||||
copy_coordinate(path->upper_bound_block[0], (float[]){100,250});
|
||||
copy_coordinate(path->lower_bound_block[1], (float[]){100,0});
|
||||
copy_coordinate(path->upper_bound_block[1], (float[]){250,80});
|
||||
copy_coordinate(path->lower_bound_block[2], (float[]){250,0});
|
||||
copy_coordinate(path->upper_bound_block[2], (float[]){360,140});
|
||||
copy_coordinate(path->lower_bound_block[3], (float[]){360,70});
|
||||
copy_coordinate(path->upper_bound_block[3], (float[]){600,140});
|
||||
copy_coordinate(path->lower_bound_block[4], (float[]){600,90});
|
||||
copy_coordinate(path->upper_bound_block[4], (float[]){720,300});
|
||||
copy_coordinate(path->lower_bound_block[5], (float[]){300,300});
|
||||
copy_coordinate(path->upper_bound_block[5], (float[]){720,350});
|
||||
copy_coordinate(path->lower_bound_block[6], (float[]){0,250});
|
||||
copy_coordinate(path->upper_bound_block[6], (float[]){410,300});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
copy_coordinate(path->lower_bound_block[4], (float[]){0,0});
|
||||
copy_coordinate(path->upper_bound_block[4], (float[]){150,250});
|
||||
copy_coordinate(path->lower_bound_block[3], (float[]){150,40});
|
||||
copy_coordinate(path->upper_bound_block[3], (float[]){250,150});
|
||||
copy_coordinate(path->lower_bound_block[2], (float[]){250,80});
|
||||
copy_coordinate(path->upper_bound_block[2], (float[]){360,200});
|
||||
copy_coordinate(path->lower_bound_block[1], (float[]){360,70});
|
||||
copy_coordinate(path->upper_bound_block[1], (float[]){600,150});
|
||||
copy_coordinate(path->lower_bound_block[0], (float[]){600,90});
|
||||
copy_coordinate(path->upper_bound_block[0], (float[]){760,300});
|
||||
copy_coordinate(path->lower_bound_block[6], (float[]){260,300});
|
||||
copy_coordinate(path->upper_bound_block[6], (float[]){760,360});
|
||||
copy_coordinate(path->lower_bound_block[5], (float[]){0,250});
|
||||
copy_coordinate(path->upper_bound_block[5], (float[]){410,300});
|
||||
|
||||
|
||||
|
||||
|
||||
copy_coordinate(path->lower_bound_block[0], (float[]){0,0});
|
||||
copy_coordinate(path->upper_bound_block[0], (float[]){150,250});
|
||||
copy_coordinate(path->lower_bound_block[1], (float[]){150,0});
|
||||
copy_coordinate(path->upper_bound_block[1], (float[]){250,150});
|
||||
copy_coordinate(path->lower_bound_block[2], (float[]){250,80});
|
||||
copy_coordinate(path->upper_bound_block[2], (float[]){360,200});
|
||||
copy_coordinate(path->lower_bound_block[3], (float[]){360,70});
|
||||
copy_coordinate(path->upper_bound_block[3], (float[]){600,170});
|
||||
copy_coordinate(path->lower_bound_block[4], (float[]){600,90});
|
||||
copy_coordinate(path->upper_bound_block[4], (float[]){760,300});
|
||||
copy_coordinate(path->lower_bound_block[5], (float[]){300,300});
|
||||
copy_coordinate(path->upper_bound_block[5], (float[]){760,350});
|
||||
copy_coordinate(path->lower_bound_block[6], (float[]){0,250});
|
||||
copy_coordinate(path->upper_bound_block[6], (float[]){410,300});
|
||||
|
||||
|
||||
|
||||
copy_coordinate(path->lower_bound_block[0], (float[]){0,300});
|
||||
copy_coordinate(path->upper_bound_block[0], (float[]){400,700});
|
||||
copy_coordinate(path->lower_bound_block[1], (float[]){100,0});
|
||||
copy_coordinate(path->upper_bound_block[1], (float[]){1000,300});
|
||||
copy_coordinate(path->lower_bound_block[2], (float[]){1000,50});
|
||||
copy_coordinate(path->upper_bound_block[2], (float[]){1400,500});
|
||||
copy_coordinate(path->lower_bound_block[3], (float[]){1400,200});
|
||||
copy_coordinate(path->upper_bound_block[3], (float[]){1800,700});
|
||||
copy_coordinate(path->lower_bound_block[4], (float[]){1100,700});
|
||||
copy_coordinate(path->upper_bound_block[4], (float[]){1700,1000});
|
||||
copy_coordinate(path->lower_bound_block[5], (float[]){800,600});
|
||||
copy_coordinate(path->upper_bound_block[5], (float[]){1100,975});
|
||||
copy_coordinate(path->lower_bound_block[6], (float[]){100,700});
|
||||
copy_coordinate(path->upper_bound_block[6], (float[]){800,975});
|
||||
*/
|
||||
|
||||
#else
|
||||
|
||||
copy_coordinate(path->lower_bound_block[0], (float[]){0,3});
|
||||
copy_coordinate(path->upper_bound_block[0], (float[]){4,7});
|
||||
copy_coordinate(path->lower_bound_block[1], (float[]){1,0});
|
||||
copy_coordinate(path->upper_bound_block[1], (float[]){10,3});
|
||||
copy_coordinate(path->lower_bound_block[2], (float[]){10,0.5});
|
||||
copy_coordinate(path->upper_bound_block[2], (float[]){14,5});
|
||||
copy_coordinate(path->lower_bound_block[3], (float[]){14,2});
|
||||
copy_coordinate(path->upper_bound_block[3], (float[]){18,7});
|
||||
copy_coordinate(path->lower_bound_block[4], (float[]){11,7});
|
||||
copy_coordinate(path->upper_bound_block[4], (float[]){17,10});
|
||||
copy_coordinate(path->lower_bound_block[5], (float[]){8,6});
|
||||
copy_coordinate(path->upper_bound_block[5], (float[]){11,9.75});
|
||||
copy_coordinate(path->lower_bound_block[6], (float[]){1,7});
|
||||
copy_coordinate(path->upper_bound_block[6], (float[]){8,9.75});
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
update_bounds_limits_blocks(path);
|
||||
|
||||
struct vehicle *car = create_vehicle(path);
|
||||
|
||||
config_layers *pconf = create_config_layers_from_OneD(4,(size_t[]){3,24,24,3}); /* 3 input , 3 target; 2 hidden layer with 24 neurons each */
|
||||
//config_layers *pconf = create_config_layers_from_OneD(3,(size_t[]){3,24,3}); /* 3 input , 3 target; 2 hidden layer with 24 neurons each */
|
||||
|
||||
bool randomize=true;
|
||||
float minR = -0.5, maxR = 0.5;
|
||||
//float minR = 0, maxR = 1;
|
||||
int randomRange = 500;
|
||||
size_t nb_prod_thread = 2;
|
||||
size_t nb_calc_thread = 4;
|
||||
float learning_rate = 0.0007 /*0.001*//* 0.0001*/; /* 0.000001*/ /* 0.001*/;
|
||||
struct networks_qlearning *nnetworks = create_network_qlearning(
|
||||
pconf,
|
||||
randomize, minR, maxR, randomRange,
|
||||
nb_prod_thread, nb_calc_thread,
|
||||
learning_rate
|
||||
);
|
||||
/*
|
||||
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->main_net, weight_in, ".ff_main_20240717_01h42m16s_5300.txt");
|
||||
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->target_net, weight_in, ".ff_target_20240717_01h42m16s_5300.txt");
|
||||
*/
|
||||
struct main_list_ptr_DIMENSION *m_l_dim=create_var_list_ptr_DIMENSION();
|
||||
//struct main_list_dimension *m_l_dim=create_var_list_dimension();
|
||||
|
||||
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS_PCONF(TYPE_FLOAT, nnetworks->main_net, weight_in, ".ff_main_TEST__first_learn_vehicle_50__11____9.symlink",m_l_dim);
|
||||
|
||||
for(struct list_ptr_DIMENSION *local_l_dim=m_l_dim->begin_list; local_l_dim; local_l_dim=local_l_dim->next){
|
||||
size_t i=local_l_dim->index;
|
||||
char msg[50]; sprintf(msg, " DIM[%ld] ",i);
|
||||
printDebug_dimension((local_l_dim->value), msg);
|
||||
}
|
||||
LOG("%s","==========================================");
|
||||
config_layers *base_conf=create_config_layers_from_weight_in_neurons_TYPE_FLOAT(nnetworks->main_net);
|
||||
config_layers *p_conf=create_config_layers_from_m_list_ptr_DIMENSION(m_l_dim);
|
||||
//config_layers *p_conf=create_config_layers_from_m_list_dimension(m_l_dim);
|
||||
|
||||
if(cmp_config_layers(p_conf, base_conf)==0){
|
||||
LOG("base_conf == %s\n","p_conf");
|
||||
|
||||
}else{
|
||||
LOG("base_conf != %s\n","p_conf");
|
||||
|
||||
}
|
||||
LOG("%s ", "base_conf"); print_config_layers(base_conf);
|
||||
LOG("%s ", "p_conf"); print_config_layers(p_conf);
|
||||
free_config_layers(base_conf);
|
||||
free_config_layers(p_conf);
|
||||
//free_all_var_list_dimension(m_l_dim);
|
||||
///free_all_var_list_ptr_DIMENSION(m_l_dim);
|
||||
//remove_all_ptr_type_list_ptr_DIMENSION(m_l_dim);
|
||||
purge_ptr_type_list_ptr_DIMENSION(m_l_dim);
|
||||
|
||||
//EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->target_net, weight_in, ".ff_target_20250508_17h50m56s_26300.txt");
|
||||
///EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->main_net, weight_in, ".ff_main_.symlink");
|
||||
///EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->target_net, weight_in, ".ff_target_.symlink");
|
||||
/*
|
||||
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->main_net, weight_in, ".ff_main_20250508_23h02m40s_29000.txt");
|
||||
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->target_net, weight_in, ".ff_target_20250508_23h02m40s_29000.txt");
|
||||
*/
|
||||
struct status_qlearning *qlstatus = create_status_qlearning ();
|
||||
struct delay_params *dly = create_delay_params (
|
||||
500/*size_t delay_between_episodes*/,
|
||||
50/*size_t delay_between_games*/
|
||||
);
|
||||
|
||||
struct qlearning_params *qlparams = create_qlearning_params (
|
||||
0.95/*float gamma*/,
|
||||
learning_rate,
|
||||
0 /* (not used!)float discount_factor*/,
|
||||
1.0/*0.99*//*0.0001*//*0.99*/ /*float exploration_factor*/,
|
||||
20/*long int nb_training_before_update_weight_in_target*/,
|
||||
10000/*size_t number_episodes*/
|
||||
);
|
||||
/* UPDATE_ATTRIBUTE_NEURONE_IN_ALL_LAYERS(TYPE_FLOAT, nnetworks->main_net, d_f_act , df );
|
||||
UPDATE_ATTRIBUTE_NEURONE_IN_ALL_LAYERS(TYPE_FLOAT, nnetworks->main_net, f_act, f );
|
||||
UPDATE_ATTRIBUTE_NEURONE_IN_ALL_LAYERS(TYPE_FLOAT, nnetworks->target_net, d_f_act , df );
|
||||
UPDATE_ATTRIBUTE_NEURONE_IN_ALL_LAYERS(TYPE_FLOAT, nnetworks->target_net, f_act , f );
|
||||
*/
|
||||
qlparams->caller_func_name=malloc(strlen(__func__)+1);
|
||||
strcpy(qlparams->caller_func_name, __func__);
|
||||
|
||||
|
||||
struct print_params *pprint = create_print_params(
|
||||
12/*float scale_x*/,12 /*float scale_y*/,
|
||||
dly/*struct delay_params * dly_p*/
|
||||
);
|
||||
|
||||
struct RL_agent *rlAgent = create_RL_agent (
|
||||
nnetworks /*struct networks_qlearning * networks*/,
|
||||
car /*struct vehicle * car*/,
|
||||
qlstatus /*struct status_qlearning * status*/,
|
||||
pprint /*struct print_params * pprint*/,
|
||||
qlparams/*struct qlearning_params *qlearnParams*/
|
||||
);
|
||||
|
||||
|
||||
//learn_to_drive(rlAgent);
|
||||
//learn_to_drive(rlAgent);
|
||||
|
||||
struct arg_bash *bash_arg= create_arg_bash();
|
||||
|
||||
struct arg_run_qlearn_bprint *argQL_BP = create_arg_run_qlearn_bprint(bash_arg, rlAgent);
|
||||
|
||||
struct arg_var_ * var = create_arg_var_(y_nnn_manager_handle_input, argQL_BP);
|
||||
struct y_socket_t *argS = y_socket_create("1600", 2, 3, var);
|
||||
|
||||
|
||||
pthread_t pollTh;
|
||||
pthread_create(&pollTh, NULL, y_socket_poll_fds, (void*)argS);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pthread_join(pollTh, NULL);
|
||||
//pthread_join(thread_learn, NULL);
|
||||
|
||||
y_socket_free(argS);
|
||||
free_arg_var_(var);
|
||||
free_arg_run_qlearn_bprint(argQL_BP);
|
||||
//free_RL_agent(rlAgent);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if 1
|
||||
HIDE_TEST(_first_learn_vehicle_50__11){
|
||||
size_t nb_block = 7;
|
||||
size_t dim= 2;
|
||||
struct blocks * path = create_blocks(nb_block, dim);
|
||||
|
||||
Reference in New Issue
Block a user