C++写的神经网络模型

所属分类:数值算法/人工智能
开发工具:C/C++
文件大小:955KB
下载次数:2
上传日期:2020-12-24 18:54:14
上 传 者7040099
说明:  用C++来设计实现一个神经网络类,用来表示神经网络,用于MNIST手写数字识别,内容比用python纯实现方式来的复杂,但运行效率更高,从中可以学习如何从零开始用C++手写一个BP神经网络
(Using C + + to design and implement a neural network class, used to represent the neural network, used for MNIST handwritten digit recognition, the content is more complex than using Python pure implementation, but the operation efficiency is higher, from which we can learn how to use C + + to write a BP neural network from scratch)

文件列表:
C++写的神经网络模型\data\input_label_0-9_1000.xml (4560253, 2019-04-20)
C++写的神经网络模型\data\input_label_1000.xml (4560253, 2019-04-20)
C++写的神经网络模型\data\input_label_500.xml (2263768, 2019-04-20)
C++写的神经网络模型\examples\ReLU_test.cpp (533, 2019-04-20)
C++写的神经网络模型\examples\ReLU_train.cpp (1066, 2019-04-20)
C++写的神经网络模型\examples\sigmoid_test.cpp (532, 2019-04-20)
C++写的神经网络模型\examples\sigmoid_train.cpp (1056, 2019-04-20)
C++写的神经网络模型\examples\tanh_test.cpp (638, 2019-04-20)
C++写的神经网络模型\examples\tanh_train.cpp (1182, 2019-04-20)
C++写的神经网络模型\examples\test.cpp (1187, 2019-04-20)
C++写的神经网络模型\include\Function.h (410, 2019-04-20)
C++写的神经网络模型\include\Net.h (2339, 2019-04-20)
C++写的神经网络模型\src\csv2xml.cpp (1742, 2019-04-20)
C++写的神经网络模型\src\Function.cpp (1552, 2019-04-20)
C++写的神经网络模型\src\Net.cpp (11707, 2019-04-20)
C++写的神经网络模型\data (0, 2019-04-20)
C++写的神经网络模型\examples (0, 2019-04-20)
C++写的神经网络模型\include (0, 2019-04-20)
C++写的神经网络模型\src (0, 2019-04-20)
C++写的神经网络模型 (0, 2020-12-24)

# Simple Net **Simple net** is a simple deep neural network implemented in C++based with OpenCV Mat matrix class --- ## Examples You can initialize a neural network just like bellow: ```cpp //Set neuron number of every layer vector layer_neuron_num = { 784,100,10 }; // Initialise Net and weights Net net; net.initNet(layer_neuron_num); net.initWeights(0, 0., 0.01); net.initBias(Scalar(0.5)); ``` It is very easy to train: ```cpp #include"../include/Net.h" // using namespace std; using namespace cv; using namespace liu; int main(int argc, char *argv[]) { //Set neuron number of every layer vector layer_neuron_num = { 784,100,10 }; // Initialise Net and weights Net net; net.initNet(layer_neuron_num); net.initWeights(0, 0., 0.01); net.initBias(Scalar(0.5)); //Get test samples and test samples Mat input, label, test_input, test_label; int sample_number = 800; get_input_label("data/input_label_1000.xml", input, label, sample_number); get_input_label("data/input_label_1000.xml", test_input, test_label, 200, 800); //Set loss threshold,learning rate and activation function float loss_threshold = 0.5; net.learning_rate = 0.3; net.output_interval = 2; net.activation_function = "sigmoid"; //Train,and draw the loss curve(cause the last parameter is ture) and test the trained net net.train(input, label, loss_threshold, true); net.test(test_input, test_label); //Save the model net.save("models/model_sigmoid_800_200.xml"); getchar(); return 0; } ``` It is easier to load a trained net and use: ```cpp #include"../include/Net.h" // using namespace std; using namespace cv; using namespace liu; int main(int argc, char *argv[]) { //Get test samples and the label is 0--1 Mat test_input, test_label; int sample_number = 200; int start_position = 800; get_input_label("data/input_label_1000.xml", test_input, test_label, sample_number, start_position); //Load the trained net and test. Net net; net.load("models/model_sigmoid_800_200.xml"); net.test(test_input, test_label); getchar(); return 0; } ```

近期下载者

相关文件


收藏者