2301_78144165 2024-05-08 22:35 采纳率: 100%
浏览 7
已结题

HLs设计手写数字识别程序编译通不过

第一二隐藏层激活函数编译没问题,但是后面的激活函数总是报错。错误信息如下。from ../../../src/main.cpp:1:
D:/Xilinx/Vivado/2017.4/include/gmp.h:62:0: warning: "__GMP_LIBGMP_DLL" redefined [enabled by default]
D:/Xilinx/Vivado/2017.4/include/floating_point_v7_0_bitacc_cmodel.h:135:0: note: this is the location of the previous definition
../../../src/main.cpp:235:35: error: expected constructor, destructor, or type conversion before '(' token
../../../src/main.cpp:240:20: error: 'text_overlay_label6' does not name a type
../../../src/main.cpp:240:52: error: 'i' does not name a type
../../../src/main.cpp:240:60: error: 'i' does not name a type
../../../src/main.cpp:254:30: error: expected constructor, destructor, or type conversion before '(' token
../../../src/main.cpp:258:20: error: 'text_overlay_label8' does not name a type
../../../src/main.cpp:258:52: error: 'i' does not name a type
../../../src/main.cpp:258:60: error: 'i' does not name a type
../../../src/main.cpp:271:28: error: expected constructor, destructor, or type conversion before '(' token
../../../src/main.cpp:277:27: error: expected unqualified-id before 'for'
../../../src/main.cpp:277:43: error: 'i' does not name a type
../../../src/main.cpp:277:51: error: 'i' does not name a type
../../../src/main.cpp:286:33: error: expected constructor, destructor, or type conversion before '(' token
../../../src/main.cpp:289:2: error: expected declaration before '}' token
make: *** [obj/main.o] Error 1
CRITICAL WARNING: [SIM 100] 'csim_design' failed: compilation error(s).
INFO: [SIM 3] *************** CSIM finish ***************
相关代码如下。 Sigmoid(a2,n1);

                           text_overlay_label4:for (i = 0; i < n2; i++)
                           {
                               y = 0.0;
                               text_overlay_label5:for (j = 0; j < n1;j++)
                                   //单点计算
                                   //y=w0*x0+w1*x1+w2*x2+...+w63*x63 + b
                                   y = y + weight3[j][i] * a2[j];
                               }
                               //加偏置
                               y = y + bias3[i];
                               //放入sigmoid激活函数
                               a3[i] = y;
                           }
                       Sigmoid(a3,n2);
                           //relu(a2,32);
//                         tanh_1(a2,16);
                             //softplus(a2,32);
                           //隐藏层第一层-第二层
                           text_overlay_label6:for (i = 0; i < n3; i++)
                           {
                               y = 0.0;
                               text_overlay_label7:for (j = 0; j < n2; j++)
                               {
                                   //单点计算
                                   //y=w0*x0+w1*x1+w2*x2+...+w63*x63 + b
                                   y = y + weight4[j][i] * a3[j];
                               }
                               //加偏置
                               y = y + bias4[i];
                               //放入sigmoid激活函数
                               a4[i] = y;
                           }
                          lrelu(a4,n3);
                           //relu(a2,32);
//                         tanh_1(a2,16);
                             //softplus(a2,32);
                           text_overlay_label8:for (i = 0; i < 10; i++)
                           {
                               y = 0.0;
                               text_overlay_label9:for (j = 0; j < n3; j++)
                               {
                                   //单点计算
                                   //y=w0*x0+w1*x1+w2*x2+...+w31*x31 + b
                                   y = y + weight5[j][i] * a4[j];
                               }
                               //加偏置
                               y = y + bias5[i];
                               p[i] = y;
                                    }
                               Sigmoid(p,10);
                              //relu(p,10);
//                             tanh_1(p,10);
                                //softplus(p,10);
                               double max = 0;
                                  //访问数组中的每一个元素,如果这个元素比认定的最大值max还要大,那么更新最大值
                                  for (int i = 0; i < 10; i++)
                                  {
                                      printf("%f\n",p[i]);
                                      if (p[i] > max)
                                      {
  • 写回答

14条回答 默认 最新

  • 妄北y 嵌入式领域优质创作者 2024-05-08 22:36
    关注

    以下参考免费微信小程序:皆我百晓生 作答,并由妄北y整理回复。

    从错误信息和代码来看,问题可能出现在以下几个方面:

    1. 编译器警告:__GMP_LIBGMP_DLL redefined。这个问题通常是由于在项目中重复包含了相同的头文件,导致宏定义冲突。你可以尝试在项目设置中检查包含的头文件,确保没有重复包含。

    2. 错误信息:expected constructor, destructor, or type conversion before '(' token。这个错误通常是由于在调用函数时,函数名后面缺少了一对圆括号。从你的代码来看,Sigmoid(a2,n1); 这行代码后面紧跟着一个分号,看起来像是一个单独的语句。请确保你调用函数时,函数名后面有一对圆括号,例如:Sigmoid(a2, n1);

    3. 错误信息:'text_overlay_label6' does not name a type。这个问题通常是由于在定义变量或者函数时,使用了非法的字符或者拼写错误。从你的代码来看,text_overlay_label6: 这个标签后面紧跟着一个 for 循环,这可能是导致错误的原因。请检查你的代码,确保所有的变量和函数名都是合法的,并且没有使用非法的字符。

    4. 错误信息:expected unqualified-id before 'for'。这个错误通常是由于在 for 循环的声明部分出现了语法错误。从你的代码来看,text_overlay_label6:for (i = 0; i < n3; i++) 这行代码中,text_overlay_label6: 这个标签后面紧跟着一个 for 循环,这可能是导致错误的原因。请检查你的代码,确保所有的循环声明都是正确的。

    5. 错误信息:expected declaration before '}' token。这个错误通常是由于在代码块的末尾缺少了一个分号。从你的代码来看,printf("%f\n",p[i]); 这行代码后面紧跟着一个花括号,这可能是导致错误的原因。请检查你的代码,确保所有的语句后面都有一个分号。

    综上所述,你需要仔细检查你的代码,确保所有的函数调用、变量名、循环声明等都是正确的。同时,检查项目设置,确保没有重复包含相同的头文件。希望这些建议能帮助你解决问题。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(13条)

报告相同问题?

问题事件

  • 系统已结题 5月17日
  • 已采纳回答 5月9日
  • 创建了问题 5月8日

悬赏问题

  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 被蓝屏搞吐了,有偿求帮解答,Ai回复直接拉黑
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并