Add some MACRO in neuron_t and debug deepQlearning
This commit is contained in:
@@ -627,6 +627,19 @@ void print_neurons_msg_##type(neurons_##type *nr, char *msg){\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
void print_weight_in_neurons_##type(neurons_##type *nn, char *msg){\
|
||||
neurons_##type *tmp = nn;\
|
||||
size_t i = 0;\
|
||||
char vmsg[250];\
|
||||
while(tmp){\
|
||||
if(tmp->weight_in){\
|
||||
sprintf(vmsg,"%s layer %ld",msg,i++);\
|
||||
print_tensor_msg_##type(tmp->weight_in, vmsg);\
|
||||
}\
|
||||
tmp = tmp->next_layer;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
void free_neurons_##type(neurons_##type *base){\
|
||||
neurons_##type *temp = base, *ttemp;\
|
||||
while(temp){\
|
||||
@@ -747,7 +760,7 @@ 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){\
|
||||
neurons_##type * 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){\
|
||||
@@ -755,6 +768,7 @@ void calculate_output_by_network_neurons_##type(neurons_##type *base, tensor_##t
|
||||
if(tmp->next_layer==NULL){\
|
||||
/*print_tensor_msg_##type(tmp->output,"retult");*/\
|
||||
*output_link = tmp->output;\
|
||||
return tmp;\
|
||||
}\
|
||||
tmp = tmp->next_layer;\
|
||||
}\
|
||||
|
||||
@@ -77,7 +77,9 @@ void setup_networks_layers_without_weights_##type(neurons_##type **base_nr, size
|
||||
void setup_networks_layers_without_weights_from_config_##type(neurons_##type **base, config_layers *pconf);\
|
||||
void setup_networks_OneD_##type(neurons_##type **base_nr, size_t *array_dim_in_layers, size_t nb_layers, bool randomize, type minR, type maxR, int randomRange);\
|
||||
void init_in_out_all_networks_OneD_##type(neurons_##type *nr, type *in, size_t sz_in, type *out, size_t sz_out);\
|
||||
\
|
||||
void print_neurons_msg_##type(neurons_##type *nr, char * msg);\
|
||||
void print_weight_in_neurons_##type(neurons_##type *nn, char *msg);\
|
||||
\
|
||||
void free_neurons_##type(neurons_##type *base);\
|
||||
\
|
||||
@@ -106,7 +108,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);\
|
||||
neurons_##type * 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);\
|
||||
\
|
||||
@@ -134,4 +136,33 @@ GEN_NEURON_(TYPE_DOUBLE)
|
||||
}\
|
||||
}while(0);\
|
||||
|
||||
#define COPY_NN_ATTRIBUTE_IN_ALL_LAYERS(type, attribute, dstNN ,sourceNN)\
|
||||
do{\
|
||||
neurons_##type *tmpn = dstNN;\
|
||||
neurons_##type *srcNN = sourceNN;\
|
||||
while(tmpn){\
|
||||
if(tmpn->attribute)\
|
||||
copy_tensor_##type(tmpn->attribute, srcNN->attribute);\
|
||||
tmpn = tmpn->next_layer;\
|
||||
srcNN = srcNN->next_layer;\
|
||||
}\
|
||||
}while(0);\
|
||||
|
||||
|
||||
|
||||
#define PRINT_ATTRIBUTE_TENS_IN_ALL_LAYERS(type, neuronVar, attribute, msg)\
|
||||
do{\
|
||||
neurons_##type *tmpn = neuronVar;\
|
||||
char *vmsg=malloc(strlen(msg)+70);\
|
||||
size_t i=0;\
|
||||
while(tmpn){\
|
||||
sprintf(vmsg,"%s layer %ld",msg,i++);\
|
||||
if(tmpn->attribute)\
|
||||
print_tensor_msg_##type(tmpn->attribute, vmsg);\
|
||||
tmpn = tmpn->next_layer;\
|
||||
}\
|
||||
free(vmsg);\
|
||||
}while(0);\
|
||||
|
||||
|
||||
#endif /*__NEURON_T_C__H*/
|
||||
|
||||
Reference in New Issue
Block a user