From 8c9b2562429fddf8d9eba49b18ada116c8d28ca3 Mon Sep 17 00:00:00 2001 From: Qiea <1310371422@qq.com> Date: Tue, 12 Nov 2024 14:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PORTING/CNN/cnn.c | 11 ++++++++--- PORTING/CNN/tools.c | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/PORTING/CNN/cnn.c b/PORTING/CNN/cnn.c index 6cbcc2c..00706de 100644 --- a/PORTING/CNN/cnn.c +++ b/PORTING/CNN/cnn.c @@ -321,11 +321,12 @@ void cnn_run(){ //初始化:生成100 * 100 矩阵 float* _data = generateMatrix(data,&value[0]); - printf("检测到放电!最大值:%f 平均值:%f 标准差:%f\r\n",value[0],value[1],value[2]); + DEBUG_PRINTF("检测到放电!最大值:%f 平均值:%f 标准差:%f\r\n",value[0],value[1],value[2]); char* _uuid = uuid(); send_blocks(_data,_uuid); //第一层:填充102 * 102 + DEBUG_PRINTF("第一层开始\n"); float* expand_matrix_1 = expand(_data, 100, 1); float* conv_rlst_1 = convolution(conv1_weight,conv1_bias,expand_matrix_1, 102); float* pool_rslt_1 = pooling(conv1_weight, conv_rlst_1, 100); @@ -338,6 +339,7 @@ void cnn_run(){ conv_rlst_1 = NULL; //第二层:填充32 * 52 * 52 + DEBUG_PRINTF("第二层开始\n"); float* expand_matrix_2 = expand(pool_rslt_1, 50, 32); float* conv_rlst_2 = convolution(conv2_weight,conv2_bias,expand_matrix_2, 52); float* pool_rslt_2 = pooling(conv2_weight, conv_rlst_2, 50); @@ -350,6 +352,7 @@ void cnn_run(){ conv_rlst_2 = NULL; //第三层:填充 64 * 27 * 27 + DEBUG_PRINTF("第三层开始\n"); float* expand_matrix_3 = expand(pool_rslt_2, 25, 64); float* conv_rlst_3 = convolution(conv3_weight,conv3_bias,expand_matrix_3, 27); float* pool_rslt_3 = pooling(conv3_weight, conv_rlst_3, 25); @@ -361,10 +364,12 @@ void cnn_run(){ myfree(SRAMEX,conv_rlst_3); conv_rlst_3 = NULL; + DEBUG_PRINTF("第四层开始\n"); float* affine1_rslt = hidden(pool_rslt_3); + DEBUG_PRINTF("第五层开始\r\n"); float* affine2_rslt = output(affine1_rslt); - printf("概率:%f\r\n",calculate_probabilities(affine2_rslt)); + printf("概率:%f\n",calculate_probabilities(affine2_rslt)); printf("Label is:%d\r\n",calculate_layer(affine2_rslt)); myfree(SRAMEX,pool_rslt_3); @@ -375,6 +380,6 @@ void cnn_run(){ affine2_rslt = NULL; } else{ - printf("未放电!最大值:%f 平均值:%f 标准差:%f\r\n",value[0],value[1],value[2]); + DEBUG_PRINTF("未放电!最大值:%f 平均值:%f 标准差:%f\r\n",value[0],value[1],value[2]); } } diff --git a/PORTING/CNN/tools.c b/PORTING/CNN/tools.c index b2160b7..0142bd9 100644 --- a/PORTING/CNN/tools.c +++ b/PORTING/CNN/tools.c @@ -44,7 +44,7 @@ void send_blocks(float* arr, char* uuid_str){ memset(_block, 0 ,sizeof(char)*100*100); block_index = 0; // 重置块 sprintf(_block, "{\"uuid\":\"%s\",\"Bid\":\"%d\",\"Eid\":\"%d\",\"Block\":\"%s\"}\n", uuid_str, total_len++, _total_len, block); - printf("%s", _block); + DEBUG_PRINTF("%s", _block); myfree(SRAMEX,_block); _block = NULL; } @@ -57,7 +57,7 @@ void send_blocks(float* arr, char* uuid_str){ memset(_block, 0 ,sizeof(char)*100*100); block_index = 0; sprintf(_block, "{\"uuid\":\"%s\",\"Bid\":\"%d\",\"Eid\":\"%d\",\"Block\":\"%s\"}\n", uuid_str, total_len, _total_len, block); - printf("%s", _block); + DEBUG_PRINTF("%s", _block); myfree(SRAMEX,_block); _block = NULL; }