BP神经网络的C语言实现
此项目使用C语言(C99)实现BP神经网络,其分为两个部分:
- 训练器;
- 适配器 训练器对原始数据进行训练、验证,并且生成BP神经网络参数文件,适配器使用训练器训练好的参数对输入给出相应的输出。
本项目实现了BP神经网络,并且产生了两个可执行文件对实现进行验证。
测试输入为3个[0,1]的浮点数据a,b,c,其输出结果为(a+b+c)/3.
- git clone https://github.com/ThreeClassMrWang/c-bpnn.git
- cd c-bpnn
- mkdir build
- cd build
- cmake ..
- make
- ./test_bpnn_train
- ./test_bpnn
- 此BP神经网络要求输入必须归一化处理;
- bpnn.h及bpnn.c为训练器的实现代码,test_bpnn_train.c对其进行测试;
- bpnn_fit.h及bpnn_fit.c为适配器代码,利用训练器出来的网络参数文件对输入给出相应的输出;
- 在bpnn_config.h中可以对数据输入输出的维度、迭代次数、学习率及临界累积误差进行配置。
- 实际使用时,需要先使用数据训练BP神经网络,然后得到网络参数文件,再利用参数文件调用适配器。