diff --git a/cnn.c b/cnn.c index ae7ceda..1833785 100644 --- a/cnn.c +++ b/cnn.c @@ -165,13 +165,14 @@ float* hidden(const float* input_matrix){ return affine1_rslt; } -float* output(const float* input_matrix){ +float* output(Model model_w, const float* input_matrix){ + u8 num = model_w.num_kernels; float affine2_temp; // 临时变量,用于存储输出层的中间结果 - float *affine2_rslt = (float *) malloc(sizeof(float)*7); - memset(affine2_rslt, 0, sizeof(float)*7); + float *affine2_rslt = (float *) malloc(sizeof(float)*num); + memset(affine2_rslt, 0, sizeof(float)*num); // 遍历10个输出神经元(假设有10个类别) - for(int n=0; n<7; n++) + for(int n=0; n