nunn:这是C ++ 17中机器学习库的实现-开源

  • w9_514100
    了解作者
  • 13.3MB
    文件大小
  • gz
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-16 02:09
    上传日期
nunn是用现代C ++ 17编写的ML算法和相关示例的集合。
nunn-1.56.tar.gz
  • nunn-1.56
  • Makefile.am
    487B
  • Makefile.in
    25.2KB
  • configure
    572.5KB
  • hopfield_test
  • Makefile.am
    307B
  • Makefile.in
    25.8KB
  • hopfield_test.cc
    5.9KB
  • hopfield_test.vcxproj.filters
    944B
  • hopfield_test.vcxproj
    14.6KB
  • compile
    7.2KB
  • config.h.in
    2.2KB
  • ltmain.sh
    316.8KB
  • configure.ac
    886B
  • ChangeLog
    97B
  • and_test
  • Makefile.am
    277B
  • Makefile.in
    25.4KB
  • and_test.vcxproj
    14.6KB
  • and_test.cc
    5.1KB
  • and_test.vcxproj.filters
    939B
  • COPYING
    17.6KB
  • depcomp
    23KB
  • install-sh
    14.8KB
  • missing
    6.7KB
  • THANKS
    68B
  • nunn_topo
  • Makefile.am
    283B
  • Makefile.in
    25.5KB
  • nunn_topo.cc
    7.8KB
  • nunn_topo.vcxproj
    12.6KB
  • winttt
  • x.bmp
    12.1KB
  • winttt.vcxproj
    15.9KB
  • o.bmp
    12.1KB
  • winttt.bmp
    1007.7KB
  • winttt.cc
    47.5KB
  • stdafx.h
    517B
  • winttt.vcxproj.filters
    1.9KB
  • stdafx.cpp
    287B
  • Resource.h
    1.1KB
  • winttt.h
    36B
  • toolbar.bmp
    5.4KB
  • targetver.h
    312B
  • winttt.ico
    14.7KB
  • small.ico
    14.7KB
  • winttt.rc
    7.2KB
  • icon.bmp
    3.1KB
  • xor_test
  • Makefile.am
    277B
  • Makefile.in
    25.4KB
  • xor_test.vcxproj.filters
    939B
  • xor_test.vcxproj
    14.6KB
  • xor_test.cc
    6.5KB
  • counter_test
  • Makefile.am
    301B
  • Makefile.in
    25.7KB
  • counter_test.vcxproj.filters
    963B
  • counter_test.cc
    5.9KB
  • counter_test.vcxproj
    14.9KB
  • tictactoe
  • Makefile.am
    283B
  • Makefile.in
    25.5KB
  • tictactoe.cc
    34.5KB
  • tictactoe.vcxproj
    16KB
  • tictactoe.vcxproj.filters
    1.2KB
  • start.sh
    42B
  • tictactoe.net
    51.9KB
  • INSTALL
    15.4KB
  • nunn
  • Makefile.am
    487B
  • Makefile.in
    21.2KB
  • nu_mlpnn.h
    5.6KB
  • nu_perceptron.h
    6.6KB
  • nu_costfuncs.h
    2.2KB
  • nu_hopfieldnn.h
    4.7KB
  • nu_xmlpnn.h
    19.7KB
  • nu_vector.h
    10KB
  • nu_neuron.h
    2.6KB
  • nu_perceptron.cc
    5.3KB
  • nunn.vcxproj.filters
    2.5KB
  • nu_trainer.h
    5.9KB
  • nu_rneuron.h
    2.2KB
  • nu_stepf.h
    1.7KB
  • nunn.vcxproj
    11.2KB
  • nu_costfuncs.cc
    2KB
  • nu_noexcept.h
    1.2KB
  • nu_sigmoid.h
    1.6KB
  • nu_rmlpnn.h
    5.5KB
  • nu_hopfieldnn.cc
    4.8KB
  • nu_mlpnn.cc
    3.3KB
  • nu_rmlpnn.cc
    3.6KB
  • nunn.vcxproj.user
    162B
  • nunn32.iss
    7.6KB
  • nunn.sln
    24.3KB
  • nunn64.iss
    7.6KB
  • mnist_test
  • Makefile.am
    345B
  • Makefile.in
    25.6KB
  • mnist_test.vcxproj
    11.8KB
内容介绍
/* * This file is part of nunnlib * * nunnlib is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * nunnlib is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with nunnlib; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US * * Author: Antonino Calderone <antonino.calderone@gmail.com rel='nofollow' onclick='return false;'> * */ /* -------------------------------------------------------------------------- */ #include "stdafx.h" #include "ocr_test.h" #include "mnist.h" #include "nu_mlpnn.h" #include <vector> #include <fstream> #include <sstream> #include <memory> #include <string> /* -------------------------------------------------------------------------- */ #define PROG_VERSION "1.56" #define ABOUT_TEXT "OCR Test by A. Calderone (c) - 2015" #define ABOUT_INFO "OCR Test Version " PROG_VERSION #define PROG_WINXRES 800 #define PROG_WINYRES 600 #define TRAINING_NET_EPOCHS 10000 #define TRAINING_NET_ERRTR 0.05 #define MAX_LOADSTRING 100 #define DIGIT_SIDE_LEN 28 #define PENSIZE 10 #define CELLSIZE 5 #define GRIDSIZE (DIGIT_SIDE_LEN*CELLSIZE) #define FRAME_SIZE 20 #define WHITEBOARD_X 100 #define WHITEBOARD_Y 130 #define YBMPOFF 100 #define FILE_FILTER "nunnlib (.net)\0*.net;\0All Files (*.*)\0*.*\0\0"; //Loading a new NN we check for the following values #define NN_INPUTS 784 #define NN_OUTPUTS 10 /* -------------------------------------------------------------------------- */ class toolbar_t { private: HWND _toolbar; HINSTANCE _hinstance; HWND _hparent; public: toolbar_t( HWND hParentWnd, HINSTANCE hInstance, UINT idi_toolbar, UINT_PTR res_id, int n_of_bitmaps, TBBUTTON buttons[], int n_of_buttons, int bmwidth = 28, int bmheight = 32, int btwidth = 28, int btheight = 32); virtual void on_resize(); virtual void on_customize(); virtual BOOL on_notify(HWND hWnd, LPARAM lParam); void enable(DWORD id); void disable(DWORD id); bool get_rect(RECT& rect); }; /* -------------------------------------------------------------------------- */ // Global Variables HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name static HFONT g_hfFont = nullptr; std::unique_ptr<nu::mlp_neural_net_t> neural_net; std::string current_file_name; std::string net_description = "Load a net description file (File->Load)"; nu::vector_t<double> g_hwdigit; /* -------------------------------------------------------------------------- */ // Toolbar static toolbar_t * gtb = nullptr; const int gtb_n_of_bmps = 4; const int gtb_btn_state = TBSTATE_ENABLED; const int gtb_btn_style = BTNS_BUTTON /*| TBSTATE_ELLIPSES*/; TBBUTTON gtb_buttons[] = { { 0, 0, TBSTATE_ENABLED, BTNS_SEP,{ 0 }, NULL, NULL }, { 0, IDM_LOAD, gtb_btn_state, gtb_btn_style,{ 0 }, NULL, (INT_PTR) "Load" }, { 1, IDM_SAVE, gtb_btn_state, gtb_btn_style,{ 0 }, NULL, (INT_PTR) "Save" }, { 0, 0, TBSTATE_ENABLED, BTNS_SEP,{ 0 }, NULL, NULL }, { 2, IDM_CLS, gtb_btn_state, gtb_btn_style,{ 0 }, NULL, (INT_PTR) "Clear" }, { 0, 0, TBSTATE_ENABLED, BTNS_SEP,{ 0 }, NULL, NULL }, { 3, IDM_RECOGNIZE, gtb_btn_state, gtb_btn_style,{ 0 }, NULL, (INT_PTR) "Recognize" }, }; const int gtb_n_of_buttons = sizeof(gtb_buttons) / sizeof(TBBUTTON); /* -------------------------------------------------------------------------- */ // Forward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); /* -------------------------------------------------------------------------- */ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_OCR_TEST, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance(hInstance, nCmdShow)) return FALSE; hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_OCR_TEST)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int)msg.wParam; } /* -------------------------------------------------------------------------- */ ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_OCR_TEST)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszMenuName = MAKEINTRESOURCE(IDC_OCR_TEST); wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); return RegisterClassEx(&wcex); } /* -------------------------------------------------------------------------- */ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) return FALSE; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } /* -------------------------------------------------------------------------- */ bool LoadNetData(HWND hWnd, HINSTANCE hInst) { std::vector<char> open_file_name(MAX_PATH); open_file_name[0] = '\0'; OPENFILENAME ofn = { sizeof(OPENFILENAME) }; ofn.hwndOwner = hWnd; ofn.hInstance = hInst; ofn.lpstrFile = open_file_name.data(); ofn.nMaxFile = (DWORD)open_file_name.size() - 1; ofn.lpstrFilter = FILE_FILTER; ofn.lpstrCustomFilter = 0; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 0; ofn.lpstrTitle = "Open File"; ofn.Flags = OFN_HIDEREADONLY; if (::GetOpenFileName(&ofn)) { std::ifstream nf(open_file_name.data()); std::stringstream ss; if (!nf.is_open()) { MessageBox( hWnd, "Cannot open the file", open_file_name.data(), MB_ICONERROR); return false; } ss << nf.rdbuf(); nf.close(); current_file_name = open_file_name.data(); auto nn = std::make_unique< nu::mlp_neural_net_t >(); try { if (nn) nn->load(ss); if (!nn || nn->get_inputs_count() != NN_INPUTS || nn->get_outputs_count() != NN_OUTPUTS) { MessageBox( hWnd, "Invalid network topology detected. " "It might be an invalid net status file for this application", open_file_name.data(), MB_ICO
评论
    相关推荐
    • 机器学习算法
      机器学习算法python实现,,,, 机器学习算法。。。。。
    • NearestNeighbours:机器学习算法
      机器学习算法 输入包含两个文件。 第一个文件包含交叉验证信息,第二个文件包含数据。 第一个档案 每行中的数字用单个空格分隔。 第一个数字是k折交叉验证方案中使用的k折的k。 第二个数字是m,即示例数。 第三个...
    • 机器学习算法SVM
      算法简单的实现了SVM算法的基本原理,利于读者初步理解 学习SVM算法
    • 基础机器学习算法
      机器学习算法应用套路:数据处理(采集+去噪),模型训练(特征+模型),模型评估(MSE/F1Score/AUC)、模型应用
    • 机器学习算法之PCA
      机器学习算法,PCA算法,故障检测算法。可运行。机器学习算法,PCA算法,故障检测算法。可运行
    • 机器学习算法
      整合了聚类,分类,最优化,最短距离,蚁群算法等其它经典算法。完整的python处理程序。
    • 机器学习算法基础
      30个小时知识无盲区课程,覆盖十多个行业应用。
    • 机器学习算法统一
      机器学习算法统一
    • 机器学习算法工具箱
      机器学习算法工具箱,包括各种机器学习的算法(mstlab).
    • 机器学习算法
      用python3完成线性回归、逻辑回归的小练习,用到sklearn库中linear_model里面的函数