{"id":13438203,"url":"https://github.com/LiuXiaolong19920720/simple_net","last_synced_at":"2025-03-19T18:32:26.869Z","repository":{"id":49354523,"uuid":"76551421","full_name":"LiuXiaolong19920720/simple_net","owner":"LiuXiaolong19920720","description":"A simple deep neural network implemented in C++，based with OpenCV Mat matrix class","archived":false,"fork":false,"pushed_at":"2019-04-20T07:59:11.000Z","size":2202,"stargazers_count":311,"open_issues_count":3,"forks_count":128,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-10-27T23:25:05.757Z","etag":null,"topics":["cpp","neural-network","opencv"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiuXiaolong19920720.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-15T10:50:02.000Z","updated_at":"2024-10-16T08:36:59.000Z","dependencies_parsed_at":"2022-08-02T14:45:45.365Z","dependency_job_id":null,"html_url":"https://github.com/LiuXiaolong19920720/simple_net","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuXiaolong19920720%2Fsimple_net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuXiaolong19920720%2Fsimple_net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuXiaolong19920720%2Fsimple_net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiuXiaolong19920720%2Fsimple_net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiuXiaolong19920720","download_url":"https://codeload.github.com/LiuXiaolong19920720/simple_net/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244483570,"owners_count":20460140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","neural-network","opencv"],"created_at":"2024-07-31T03:01:03.643Z","updated_at":"2025-03-19T18:32:26.864Z","avatar_url":"https://github.com/LiuXiaolong19920720.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Simple Net\n**Simple net** is a simple deep neural network implemented in C++，based with OpenCV Mat matrix class\n\n---\n\n## Examples\nYou can initialize a neural network just like bellow:\n```cpp\n\t//Set neuron number of every layer\n\tvector\u003cint\u003e layer_neuron_num = { 784,100,10 };\n\n\t// Initialise Net and weights\n\tNet net;\n\tnet.initNet(layer_neuron_num);\n\tnet.initWeights(0, 0., 0.01);\n\tnet.initBias(Scalar(0.5));\n```\n\nIt is very easy to train:\n\n```cpp\n#include\"../include/Net.h\"\n//\u003copencv2\\opencv.hpp\u003e\n\nusing namespace std;\nusing namespace cv;\nusing namespace liu;\n\nint main(int argc, char *argv[])\n{\n\t//Set neuron number of every layer\n\tvector\u003cint\u003e layer_neuron_num = { 784,100,10 };\n\n\t// Initialise Net and weights\n\tNet net;\n\tnet.initNet(layer_neuron_num);\n\tnet.initWeights(0, 0., 0.01);\n\tnet.initBias(Scalar(0.5));\n\n\t//Get test samples and test samples \n\tMat input, label, test_input, test_label;\n\tint sample_number = 800;\n\tget_input_label(\"data/input_label_1000.xml\", input, label, sample_number);\n\tget_input_label(\"data/input_label_1000.xml\", test_input, test_label, 200, 800);\n\n\t//Set loss threshold,learning rate and activation function\n\tfloat loss_threshold = 0.5;\n\tnet.learning_rate = 0.3;\n\tnet.output_interval = 2;\n\tnet.activation_function = \"sigmoid\";\n\n\t//Train,and draw the loss curve(cause the last parameter is ture) and test the trained net\n\tnet.train(input, label, loss_threshold, true);\n\tnet.test(test_input, test_label);\n\n\t//Save the model\n\tnet.save(\"models/model_sigmoid_800_200.xml\");\n\n\tgetchar();\n\treturn 0;\n}\n```\n\nIt is easier to load a trained net and use:\n```cpp\n#include\"../include/Net.h\"\n//\u003copencv2\\opencv.hpp\u003e\n\nusing namespace std;\nusing namespace cv;\nusing namespace liu;\n\nint main(int argc, char *argv[])\n{\n\t//Get test samples and the label is 0--1\n\tMat test_input, test_label;\n\tint sample_number = 200;\n\tint start_position = 800;\n\tget_input_label(\"data/input_label_1000.xml\", test_input, test_label, sample_number, start_position);\n\n\t//Load the trained net and test.\n\tNet net;\n\tnet.load(\"models/model_sigmoid_800_200.xml\");\n\tnet.test(test_input, test_label);\n\n\tgetchar();\n\treturn 0;\n}\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLiuXiaolong19920720%2Fsimple_net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLiuXiaolong19920720%2Fsimple_net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLiuXiaolong19920720%2Fsimple_net/lists"}