Click here to Skip to main content
13,550,547 members
Click here to Skip to main content


564 bookmarked
Posted 5 Dec 2006

Neural Network for Recognition of Handwritten Digits

, 5 Dec 2006
A convolutional neural network achieves 99.26% accuracy on a modified NIST database of hand-written digits.
// MNist.h : main header file for the MNIST application

#if !defined(AFX_MNIST_H__905CA67E_F9A3_448F_9B1D_0210659E4E2A__INCLUDED_)
#define AFX_MNIST_H__905CA67E_F9A3_448F_9B1D_0210659E4E2A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH

#include "resource.h"       // main symbols
#include "Preferences.h"	// Added by ClassView

// private message number

		_T("UWM_BACKPROPAGATION_NOTIFICATION-{F4BB541B-473D-46d3-B8D0-2C8CA6058769}") );  

const UINT UWM_TESTING_NOTIFICATION = ::RegisterWindowMessage( 
		_T("UWM_TESTING_NOTIFICATION-{86B3253A-79DF-4f7a-87A7-D99E4B275B14}") );  

// declare global GetPreferences function

const CPreferences& GetPreferences();

// declare global SetThreadName function

void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName);

// global function to support 64-bit atomic compare-and-exchange
// Probably will work only on Intel and AMD products, and no others
// Needed since the windows API provides an InterlockedCompareExchange64 function only for 
// "Vista" and higher, and because I do not have access to the VC++ 2005 compiler
// intrinsic _InterlockedCompareExchange64.
// See my newsgroup post:
// "InterlockedCompareExchange64 under VC++ 6.0: in-line assembly using cmpxchg8b ??"
// at:
// The following code was obtained from:

#pragma warning(push)
#pragma warning(disable : 4035) // disable no-return warning

inline unsigned __int64 
_InterlockedCompareExchange64(volatile unsigned __int64 *dest,
                           unsigned __int64 exchange,
                           unsigned __int64 comparand) 
    //value returned in eax::edx
    __asm {
        lea esi,comparand;
        lea edi,exchange;
        mov eax,[esi];
        mov edx,4[esi];
        mov ebx,[edi];
        mov ecx,4[edi];
        mov esi,dest;
        //lock CMPXCHG8B [esi] is equivalent to the following except
        //that it's atomic:
        //ZeroFlag = (edx:eax == *esi);
        //if (ZeroFlag) *esi = ecx:ebx;
        //else edx:eax = *esi;
        lock CMPXCHG8B [esi];			

#pragma warning(pop)

// CMNistApp:
// See MNist.cpp for the implementation of this class

class CMNistApp : public CWinApp
	CPreferences m_Preferences;
	CString m_sModulePath;

// Overrides
	// ClassWizard generated virtual function overrides
	virtual BOOL InitInstance();

// Implementation
	afx_msg void OnAppAbout();
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !


// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MNIST_H__905CA67E_F9A3_448F_9B1D_0210659E4E2A__INCLUDED_)

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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Mike O'Neill
United States United States
Mike O'Neill is a patent attorney in Southern California, where he specializes in computer and software-related patents. He programs as a hobby, and in a vain attempt to keep up with and understand the technology of his clients.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180515.1 | Last Updated 5 Dec 2006
Article Copyright 2006 by Mike O'Neill
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid