Click here to Skip to main content
15,891,828 members
Articles / Programming Languages / C

Backpropagation Artificial Neural Network in C++

Rate me:
Please Sign up or sign in to vote.
4.88/5 (29 votes)
20 May 2008GPL38 min read 209K   10.2K   104  
This article demonstrates a backpropagation artificial neural network console application with validation and test sets for performance estimation using uneven distribution metrics.
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once
#pragma warning(disable : 4996)


#include <iostream>
#include <tchar.h>

// TODO: reference additional headers your program requires here
#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <wchar.h>
#include <conio.h>
#include <time.h>

#include <vector>
#include <algorithm>

using namespace std;



typedef struct _entry {
        float *vec;                //vector
        int size;                  //vector size
        wchar_t fname[_MAX_PATH];  //vector file name
        int cls;                   //vector class
} ENTRY, *PENTRY;

typedef struct _rec {
        vector<PENTRY> entries;         //rec entries
        vector< vector<int> > indices;  //2D array of classes indices
        vector<int> clsnum;             //classes numbers of indeces columns
} REC, *PREC;

/*
   2D type array

    [entry ... vec ...]   (+ size,fname,class type)
    [entry ... vec ...]
    [entry ... vec ...]
    [entry ... vec ...]
     ...
    N = rec.size()

    individual point - rec.entries[y].vec[x]


    indices to y axis of entries vector
     vector<int> x0;  vector<int> x1; vector<int> x2; ... vector<int> xClassesNum

    clsnum[0],clsnum[1], ... clsnum[N]
      [x0][x1][x2][x3] ... [xN]    N different classes
      [x0][x1][x2][x3] ... [xN]
      [x0][x1][x2][x3] ... [xN]
          [x1][x2]
          [x1]
          ...

    example
      rec->clsnum[] =   3, 1, 2    <--  1D vector

                        0  1  8    <--  rec->indices[x].at(y)  2D array
                       10  5  9
                        3  2
                        4  6

                                     */



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Engineer
Russian Federation Russian Federation
Highly skilled Engineer with 14 years of experience in academia, R&D and commercial product development supporting full software life-cycle from idea to implementation and further support. During my academic career I was able to succeed in MIT Computers in Cardiology 2006 international challenge, as a R&D and SW engineer gain CodeProject MVP, find algorithmic solutions to quickly resolve tough customer problems to pass product requirements in tight deadlines. My key areas of expertise involve Object-Oriented
Analysis and Design OOAD, OOP, machine learning, natural language processing, face recognition, computer vision and image processing, wavelet analysis, digital signal processing in cardiology.

Comments and Discussions