|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Ads Donate Humor |
|
|
"Visible" neural network program for MS Visual C++ Studio 2005This is the multilayer perceptron backpropagation neural net program Version 2.0 converted to Microsoft Visual C++ Studio 2005, .NET Framework, and the Standard Template Library.This version of the program is the most current, and is the only one in which further development will be done. At 5/10/2007 it is an alpha version. Creation and training of networks, and the graphic display, are tested and appear to operate properly. Saving networks to and from disk, and possibly other features, remain untested. The web page for the earlier version, WNeural, has notes and screenshots that are also relevant to this version.
The web page source code listings for this version are: VCPPNetwork.cpp. The network classes. Platform independent, STL. VCNEURAL.CPP. A Windows application that creates a network and displays it graphically while it runs. Code listing is farther down this page. DownloadDownload vcppneural.zip (about 51 KB) The zip contains the files listed below. I think the best way to build this project is to create a new solution from scratch in Visual Studio, replace the contents of your default Form1.h with the contents of this one, then copy the other files into your solution folder and add them to the solution. I'm only guessing about that, but I once tried to create a "Project from existing code...", and wound up with errors. A web search found other people who had gotten the same errors after the same process. I think these are all the project-specific files you need to create the project, but I am so new to Visual Studio that I'm not sure. If something is missing, please let me know. These are the only files I created. All of the other (numerous) files in the project were auto-generated by Visual Studio. You will also need the non-project-specific file my.h, and in future versions you might also need mylib.cpp.
|
/* Form1.h 5-9-2007
This is part of the VCNeural project for MS Visual C++ Studio 2005.
This file is the successor to WNeural.cpp. It contains the code for the
main window, which is now called a Form.
Copyright (C)1995-99, 2007 Steven Whitney.
Initially published by http://25yearsofprogramming.com.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Version 2 as published by the Free Software Foundation.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
(Adapted from WNeural.cpp Version 2.0)
A multilayer perceptron neural network that you can watch on the screen as it "thinks".
------
TO DO:
--measure the Timer method against the P5-90, loops/sec. If it's slower, research how to
insert my own message handler (message loop?). Look at the OWL source code to see
where and how it invokes IdleAction. Maybe I can do the same.
I don't like the Timer method in general. IdleAction accomplished more in less time
and didn't slow down system responsiveness any more than Timer does.
------
NOTES:
FILES:
-- *.TRS Training set data, problems and solutions.
-- *.NET Node connection data for rebuilding a network from disk.
*/
#pragma once
#include "InputDialog.h"
#include "PeekLevelDialog.h"
#include "network.h"
#include <time.h>
#include "..\..\mylib\mylib.cpp"
namespace VCNeural {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Diagnostics;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
//--------------------------------------------------------------------------------
// constructor
Form1(void)
{
InitializeComponent();
//TODO: Add the constructor code here
// initialize pointers
net = new NeuralNet();
sw = gcnew Stopwatch;
inputdialog = gcnew InputDialog();
peekleveldialog = gcnew PeekLevelDialog();
// initialize other variables
autocycle = false;
Iterations = 0L;
// unsure if this placement is ideal. In Borland, it had to go in OwlMain to work.
srand((unsigned)time(NULL));
} //constructor
//--------------------------------------------------------------------------------
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
IdleActionTimer->Stop();
if(components)
{
delete components;
}
if(net)
delete net;
if(sw)
delete sw;
if(inputdialog)
delete inputdialog;
if(peekleveldialog)
delete peekleveldialog;
}
//-----------------------------
// My code
// pointers
NeuralNet* net;
Stopwatch^ sw; // for timing things
InputDialog^ inputdialog; // misnamed, this is for inputting layer node counts only.
PeekLevelDialog^ peekleveldialog; // sets graphic display frequency
// other variables
long Iterations; // counts calls to net->Run() for training count/timing calculations
bool autocycle; // a master switch to force IdleAction (timer) to do nothing
//-----------------------------
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::MenuStrip^ menuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ openToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ exitToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ networkToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ newToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ loadToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ saveAsToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ viewToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ nodeNumbersToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ messagesToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ peekLevelToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ helpToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ indexToolStripMenuItem;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1;
private: System::Windows::Forms::ToolStripMenuItem^ aboutToolStripMenuItem;
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::OpenFileDialog^ openCasesDialog;
private: System::Windows::Forms::Timer^ IdleActionTimer;
private: System::Windows::Forms::SaveFileDialog^ saveNetworkDialog;
private: System::Windows::Forms::OpenFileDialog^ openNetworkDialog;
private: System::ComponentModel::IContainer^ components;
private:
/// <summary>
/// Required designer variable.
/// </summary>
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->networkToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->newToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->loadToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->saveAsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->viewToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->nodeNumbersToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->messagesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->peekLevelToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->helpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->indexToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->openCasesDialog = (gcnew System::Windows::Forms::OpenFileDialog());
this->IdleActionTimer = (gcnew System::Windows::Forms::Timer(this->components));
this->saveNetworkDialog = (gcnew System::Windows::Forms::SaveFileDialog());
this->openNetworkDialog = (gcnew System::Windows::Forms::OpenFileDialog());
this->menuStrip1->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Dock = System::Windows::Forms::DockStyle::Bottom;
this->textBox1->Font = (gcnew System::Drawing::Font(L"Courier New", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->textBox1->Location = System::Drawing::Point(0, 277);
this->textBox1->Multiline = true;
this->textBox1->Name = L"textBox1";
this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
this->textBox1->Size = System::Drawing::Size(532, 79);
this->textBox1->TabIndex = 0;
this->textBox1->Text = L"This window displays status reports. Hide it with Ctrl+M.";
//
// menuStrip1
//
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->fileToolStripMenuItem,
this->networkToolStripMenuItem, this->viewToolStripMenuItem, this->helpToolStripMenuItem});
this->menuStrip1->Location = System::Drawing::Point(0, 0);
this->menuStrip1->Name = L"menuStrip1";
this->menuStrip1->Size = System::Drawing::Size(532, 24);
this->menuStrip1->TabIndex = 1;
this->menuStrip1->Text = L"menuStrip1";
//
// fileToolStripMenuItem
//
this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->openToolStripMenuItem,
this->exitToolStripMenuItem});
this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
this->fileToolStripMenuItem->Size = System::Drawing::Size(35, 20);
this->fileToolStripMenuItem->Text = L"&File";
//
// openToolStripMenuItem
//
this->openToolStripMenuItem->Name = L"openToolStripMenuItem";
this->openToolStripMenuItem->ShortcutKeyDisplayString = L"";
this->openToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::O));
this->openToolStripMenuItem->Size = System::Drawing::Size(212, 22);
this->openToolStripMenuItem->Text = L"&Open Cases file...";
this->openToolStripMenuItem->ToolTipText = L"Load a training set from disk";
this->openToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::openToolStripMenuItem_Click);
//
// exitToolStripMenuItem
//
this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
this->exitToolStripMenuItem->Size = System::Drawing::Size(212, 22);
this->exitToolStripMenuItem->Text = L"E&xit";
this->exitToolStripMenuItem->ToolTipText = L"Exit program";
this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::exitToolStripMenuItem_Click);
//
// networkToolStripMenuItem
//
this->networkToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->newToolStripMenuItem,
this->loadToolStripMenuItem, this->saveAsToolStripMenuItem});
this->networkToolStripMenuItem->Name = L"networkToolStripMenuItem";
this->networkToolStripMenuItem->Size = System::Drawing::Size(59, 20);
this->networkToolStripMenuItem->Text = L"&Network";
//
// newToolStripMenuItem
//
this->newToolStripMenuItem->Name = L"newToolStripMenuItem";
this->newToolStripMenuItem->ShortcutKeyDisplayString = L"";
this->newToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::N));
this->newToolStripMenuItem->Size = System::Drawing::Size(152, 22);
this->newToolStripMenuItem->Text = L"&New";
this->newToolStripMenuItem->ToolTipText = L"Create a new network to your specifications";
this->newToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::newToolStripMenuItem_Click);
//
// loadToolStripMenuItem
//
this->loadToolStripMenuItem->Name = L"loadToolStripMenuItem";
this->loadToolStripMenuItem->Size = System::Drawing::Size(152, 22);
this->loadToolStripMenuItem->Text = L"&Load...";
this->loadToolStripMenuItem->ToolTipText = L"Load previously saved network architecture";
this->loadToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::loadToolStripMenuItem_Click);
//
// saveAsToolStripMenuItem
//
this->saveAsToolStripMenuItem->Name = L"saveAsToolStripMenuItem";
this->saveAsToolStripMenuItem->Size = System::Drawing::Size(152, 22);
this->saveAsToolStripMenuItem->Text = L"&SaveAs...";
this->saveAsToolStripMenuItem->ToolTipText = L"Save current network\'s architecture to a file";
this->saveAsToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveAsToolStripMenuItem_Click);
//
// viewToolStripMenuItem
//
this->viewToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->nodeNumbersToolStripMenuItem,
this->messagesToolStripMenuItem, this->peekLevelToolStripMenuItem});
this->viewToolStripMenuItem->Name = L"viewToolStripMenuItem";
this->viewToolStripMenuItem->Size = System::Drawing::Size(41, 20);
this->viewToolStripMenuItem->Text = L"&View";
//
// nodeNumbersToolStripMenuItem
//
this->nodeNumbersToolStripMenuItem->Checked = true;
this->nodeNumbersToolStripMenuItem->CheckOnClick = true;
this->nodeNumbersToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked;
this->nodeNumbersToolStripMenuItem->Name = L"nodeNumbersToolStripMenuItem";
this->nodeNumbersToolStripMenuItem->ShortcutKeyDisplayString = L"";
this->nodeNumbersToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::D3));
this->nodeNumbersToolStripMenuItem->Size = System::Drawing::Size(193, 22);
this->nodeNumbersToolStripMenuItem->Text = L"&Node Numbers";
this->nodeNumbersToolStripMenuItem->ToolTipText = L"View nodes as numbers, or dots (slower)";
this->nodeNumbersToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::nodeNumbersToolStripMenuItem_Click);
//
// messagesToolStripMenuItem
//
this->messagesToolStripMenuItem->Checked = true;
this->messagesToolStripMenuItem->CheckOnClick = true;
this->messagesToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked;
this->messagesToolStripMenuItem->Name = L"messagesToolStripMenuItem";
this->messagesToolStripMenuItem->ShortcutKeyDisplayString = L"";
this->messagesToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::M));
this->messagesToolStripMenuItem->Size = System::Drawing::Size(193, 22);
this->messagesToolStripMenuItem->Text = L"&Messages";
this->messagesToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::messagesToolStripMenuItem_Click);
//
// peekLevelToolStripMenuItem
//
this->peekLevelToolStripMenuItem->Name = L"peekLevelToolStripMenuItem";
this->peekLevelToolStripMenuItem->ShortcutKeyDisplayString = L"";
this->peekLevelToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::P));
this->peekLevelToolStripMenuItem->Size = System::Drawing::Size(193, 22);
this->peekLevelToolStripMenuItem->Text = L"&Peek level";
this->peekLevelToolStripMenuItem->ToolTipText = L"How often to update graphic node display";
this->peekLevelToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::peekLevelToolStripMenuItem_Click);
//
// helpToolStripMenuItem
//
this->helpToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->indexToolStripMenuItem,
this->toolStripSeparator1, this->aboutToolStripMenuItem});
this->helpToolStripMenuItem->Name = L"helpToolStripMenuItem";
this->helpToolStripMenuItem->Size = System::Drawing::Size(40, 20);
this->helpToolStripMenuItem->Text = L"&Help";
//
// indexToolStripMenuItem
//
this->indexToolStripMenuItem->Name = L"indexToolStripMenuItem";
this->indexToolStripMenuItem->ShortcutKeyDisplayString = L"";
this->indexToolStripMenuItem->ShortcutKeys = System::Windows::Forms::Keys::F1;
this->indexToolStripMenuItem->Size = System::Drawing::Size(132, 22);
this->indexToolStripMenuItem->Text = L"&Index";
this->indexToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::indexToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this->toolStripSeparator1->Name = L"toolStripSeparator1";
this->toolStripSeparator1->Size = System::Drawing::Size(129, 6);
//
// aboutToolStripMenuItem
//
this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem";
this->aboutToolStripMenuItem->Size = System::Drawing::Size(132, 22);
this->aboutToolStripMenuItem->Text = L"&About...";
this->aboutToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::aboutToolStripMenuItem_Click);
//
// pictureBox1
//
this->pictureBox1->Dock = System::Windows::Forms::DockStyle::Fill;
this->pictureBox1->Location = System::Drawing::Point(0, 24);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(532, 253);
this->pictureBox1->TabIndex = 3;
this->pictureBox1->TabStop = false;
this->pictureBox1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::pictureBox1_Paint);
this->pictureBox1->Resize += gcnew System::EventHandler(this, &Form1::pictureBox1_Resize);
//
// openCasesDialog
//
this->openCasesDialog->DefaultExt = L"TRS";
this->openCasesDialog->Filter = L"Training Sets (*.TRS)|*.TRS|All Files (*.*)|*.*";
this->openCasesDialog->Title = L"Open training set Cases file";
//
// IdleActionTimer
//
this->IdleActionTimer->Interval = 1;
this->IdleActionTimer->Tick += gcnew System::EventHandler(this, &Form1::IdleActionTimer_Tick);
//
// saveNetworkDialog
//
this->saveNetworkDialog->DefaultExt = L"NET";
this->saveNetworkDialog->Filter = L"Networks (*.NET)|*.NET|All Files (*.*)|*.*";
//
// openNetworkDialog
//
this->openNetworkDialog->DefaultExt = L"NET";
this->openNetworkDialog->Filter = L"Networks (*.NET)|*.NET|All Files (*.*)|*.*";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::Black;
this->ClientSize = System::Drawing::Size(532, 356);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->menuStrip1);
this->MainMenuStrip = this->menuStrip1;
this->Name = L"Form1";
this->Text = L"VCNeural Visible Neural Network";
this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &Form1::Form1_FormClosing);
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//----------------------------------------------------------------------------
// Open Cases file (training set)
private: System::Void openToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
if(openCasesDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
{
MessageBox::Show("File open canceled.","Warning");
return;
}
// user selected file, so process it
if(!openCasesDialog->FileName->ToUpper()->EndsWith(".TRS"))
{
MessageBox::Show(String::Concat(openCasesDialog->FileName->ToUpper(),"\r\nFile extension must be .TRS"),
"Cannot Load This File");
return;
}
string buf;
SystemStringToBasicString(openCasesDialog->FileName, buf);
if(!net->LoadCases(buf.c_str()))
{
MessageBox::Show(String::Concat(openCasesDialog->FileName->ToUpper(),
"\r\nFile not found, corrupt, or training sets not unique."),
"File Error");
return;
}
if(net->Cases.size())
{
Iterations = 0L;
textBox1->Text = String::Concat("Number of Cases Loaded: ", net->Cases.size());
autocycle = true;
sw->Reset(); // because cycling will start with the next IdleAction
sw->Start();
IdleActionTimer->Start();
}
else
MessageBox::Show("No sets were successfully loaded.","Warning: Training data set empty");
}
//----------------------------------------------------------------------------
private: System::Void exitToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
this->Close();
}
//----------------------------------------------------------------------------
/* Assign each Node its location on the screen. Call it whenever a new net is created or
loaded or the screen is resized.
*/
void AssignNodeLocs()
{
if(!net || !net->nw.size())
return;
int ystart = 16; // the top node is cut in half if it's 0, so what should it be?
int h = pictureBox1->Height - ystart;
int w = pictureBox1->Width;
int dyin = h / max(net->Count(INPUT), 1); // spacing of nodes down the screen
int dyh1 = h / max(net->Count(HIDDEN,1), 1); // max prevents divide by zero
int dyh2 = h / max(net->Count(HIDDEN,2), 1);
int dyh3 = h / max(net->Count(HIDDEN,3), 1);
int dyout = h / max(net->Count(OUTPUT), 1);
int dxcolumns = (w - 30) / 4; // spacing of columns (by node type) across the screen
int dxfull = 20; // when a single column fills up, next column starts this many pixels to right
// --> NOT YET IMPLEMENTED.
// The screen display is mostly for small runs. At some point, there are
// too many nodes and you just can't display them well.
int lasttype = -1; // move over to next column when type changes
for(size_t i = 0 ; i < net->nw.size() ; i++)
{
Node* n = net->nw[i];
switch(n->Type)
{
case INPUT:
n->x = 10;
if(n->Type != lasttype)
n->y = ystart; // start at column top
else
n->y = net->nw[i-1]->y + dyin;
break;
case HIDDEN:
n->x = n->HiddenLayer * dxcolumns;
switch(n->HiddenLayer)
{
case 1:
if(n->Type != lasttype)
n->y = ystart; // start at column top
else
n->y = net->nw[i-1]->y + dyh1;
break;
case 2:
if(n->HiddenLayer != net->nw[i-1]->HiddenLayer)
n->y = ystart;
else
n->y = net->nw[i-1]->y + dyh2;
break;
case 3:
if(n->HiddenLayer != net->nw[i-1]->HiddenLayer)
n->y = ystart;
else
n->y = net->nw[i-1]->y + dyh3;
break;
}
break;
case OUTPUT:
n->x = w - 20;
if(n->Type != lasttype)
n->y = ystart; // start at column top
else
n->y = net->nw[i-1]->y + dyout;
break;
}
//This old calculation for ->y if enabled replaces all the y calculations above.
//It also creates a more visually varied screen display.
//n->y = random(h);
lasttype = n->Type;
}
} // AssignNodeLocs
//----------------------------------------------------------------------------
// display the entire network graphically
// showconnect is whether to show connections; use false if just updating node fills.
void drawnodes(Graphics^ g, bool showconnect)
{
using namespace System::Drawing;
Pen^ pen = gcnew Pen(Color::White);
System::Drawing::Font^ font = gcnew System::Drawing::Font("Arial", 12);
SolidBrush^ brush = gcnew SolidBrush(Color::White);
StringFormat^ stringformat = gcnew StringFormat();
Color color;
int nwcount = net->nw.size();
for(int i = 0 ; i < nwcount ; i++)
{
Node* n = net->nw[i];
switch(n->Type) // set color for this node
{
case INPUT: color = Color::Red; break;
case HIDDEN: color = Color::Green; break;
case OUTPUT: color = Color::White; break;
}
if(net->shownodenumbers) // display as numbers
{
brush->Color = color;
g->DrawString(i.ToString(), font, brush, (float)n->x, (float)n->y, stringformat);
}
else // or display as circles.
{
// if inputs positive, solid ellipse, else just an outline.
if(n->input > 0.)
{
brush->Color = color;
g->FillEllipse(brush, n->x - 5, n->y - 5, 10, 10);
}
else
{
pen->Color = color;
g->DrawEllipse(pen, n->x - 5, n->y - 5, 10, 10);
}
}
if(!showconnect)
continue;
// Now draw the connections into this node, colored according to
// (source node's output * the connection weight).
// To do so, it must draw the connections using inlist, so it
// draws the connections coming IN to this node.
int count = n->inlist.size();
for(int j = 0 ; j < count ; j++)
{
Node* source = n->inlist[j].from;
double output = source->output;
double weight = n->inlist[j].weight;
double total = output * weight;
/*#error unfinished.
This is the eventual coloration: they need to be scaled somehow
blue(0-255) = - more than 1.0
red(0-255) = - 0 to -1
green(0-255) = + 0 to 1
white(0-255) = + more than 1.0
*/
if(total < -1.0)
color = Color::FromArgb(255,0,0,255);
else
if((total >= -1.0) && (total < 0.0))
color = Color::FromArgb(255,255,0,0);
else
if((total >= 0.0) && (total <= 1.0))
color = Color::FromArgb(255,0,255,0);
else color = Color::FromArgb(255,255,255,255);
pen->Color = color;
g->DrawLine(pen, n->inlist[j].from->x, n->inlist[j].from->y, n->x, n->y);
}
} // end for(all nodes in network)
delete pen;
delete font;
delete brush;
delete stringformat;
} // drawnodes
//----------------------------------------------------------------------------
// toggle how to display the nodes (as #s or as dots)
private: System::Void nodeNumbersToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
net->shownodenumbers = !net->shownodenumbers;
pictureBox1->Invalidate(); // force a total redraw
}
//----------------------------------------------------------------------------
//EvResize equivalent
private: System::Void pictureBox1_Resize(System::Object^ sender, System::EventArgs^ e)
{
AssignNodeLocs();
pictureBox1->Invalidate(); // force a total redraw
}
//----------------------------------------------------------------------------
// Help About box
private: System::Void aboutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show("Copyright (C)1995-97, 2007 Steven Whitney","VCNeural Visible Neural Network");
}
//----------------------------------------------------------------------------
// Paint (the picturebox)
private: System::Void pictureBox1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
{
// don't waste system time if !net or this isn't the active application, or is minimized
if(!net || (this->WindowState == FormWindowState::Minimized))
return;
e->Graphics->Clear(Color::Black); // erase window to black background
drawnodes(e->Graphics, true); // then draw on it.
}
//----------------------------------------------------------------------------
// set Peek level 0-3
private: System::Void peekLevelToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
peekleveldialog->numericUpDown1->Value = net->graphicon;
if(peekleveldialog->ShowDialog() == System::Windows::Forms::DialogResult::OK)
net->graphicon = (int)peekleveldialog->numericUpDown1->Value;
}
//----------------------------------------------------------------------------
private: System::Void messagesToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Visible = !textBox1->Visible;
}
//----------------------------------------------------------------------------
private: System::Void newToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
/* rewire the network to our specifications */
if(inputdialog->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
if(net->CreateNetwork(
(size_t)inputdialog->numericUpDownINPUTS->Value,
(size_t)inputdialog->numericUpDownHIDDEN1->Value,
(size_t)inputdialog->numericUpDownHIDDEN2->Value,
(size_t)inputdialog->numericUpDownHIDDEN3->Value,
(size_t)inputdialog->numericUpDownOUTPUTS->Value))
{
AssignNodeLocs();
IdleActionTimer->Start();
autocycle = true;
Iterations = 0L;
sw->Reset(); // because cycling will start with the next IdleAction
sw->Start();
}
else
MessageBox::Show("Please review the rules for node counts and try again.",
"Cannot create specified network.");
}
pictureBox1->Invalidate(); // erase the old display if present
}
//----------------------------------------------------------------------------
private: System::Void IdleActionTimer_Tick(System::Object^ sender, System::EventArgs^ e)
{
if(!net)
{
IdleActionTimer->Stop();
return;
}
//putchar(7); // for testing whether it's cycling under all conditions (it is)
String^ statusmsg = gcnew String("");
String^ statustitle = gcnew String("");
String^ errormsg = gcnew String("");
int result = net->Run();
switch(result)
{
case 0: // processing is in progress. No problem.
Iterations++; // this counts the calls to Run(), and overstates actual iterations.
if((net->graphicon == 3) ||
((net->graphicon == 2) && net->CurrentCaseWasSolved()))
{
pictureBox1->Invalidate();
textBox1->Text = Iterations.ToString();
}
break;
case 1: // FINISHED because the network is fully trained (training run)
IdleActionTimer->Stop();
sw->Stop();
statusmsg = String::Concat("Trained - Time: ", sw->Elapsed, ". Trials: ", Iterations);
statustitle = "Network is trained on all input Cases.";
autocycle = false;
if(net->graphicon == 1)
pictureBox1->Invalidate();
break;
case 2: // FINISHED because all Cases in a REAL RUN have been processed.
IdleActionTimer->Stop();
sw->Stop();
statusmsg = String::Concat("All Cases calculated. The result data are in the output file. Time: ",
sw->Elapsed, ". Cases solved: ", Iterations);
statustitle = "All dataset Cases have been processed.";
autocycle = false;
break;
// errors
case -1:
errormsg = "The network is not created, contains no Nodes.";
break;
case -2:
errormsg = "There is no input dataset loaded. (Cases is empty).";
break;
case -3:
errormsg = "Network and dataset incompatible: Input nodes != Inputs.";
break;
case -4:
errormsg = "Network and dataset incompatible: Output nodes != Outputs.";
break;
}
if(errormsg->Length)
{
IdleActionTimer->Stop();
autocycle = false; // prevent displaying this message repeatedly.
textBox1->Text = String::Concat("Network cannot start processing because: ", errormsg,
" When you resolve the problem, it will automatically try again.");
}
if(statusmsg->Length)
{
textBox1->Text = String::Concat(statustitle, "\r\n", statusmsg);
MessageBox::Show(statusmsg, statustitle);
}
delete statusmsg;
delete statustitle;
delete errormsg;
/*
// set up window caption
string caption = string(GetApplication()->GetName()) + string(" - ");
if(Parent)
Parent->SetCaption(caption.c_str());
*/
}
//----------------------------------------------------------------------------
// OnClose
private: System::Void Form1_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e)
{
//enable if you need this prompt.
//if(net)
// if(MessageBox::Show("Save net to disk?","Network has changed",
// System::Windows::Forms::MessageBoxButtons::YesNo) == System::Windows::Forms::DialogResult::Yes)
// SaveNetworkToDisk();
}
//----------------------------------------------------------------------------
private: System::Void saveAsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
SaveNetworkToDisk();
}
//----------------------------------------------------------------------------
private: void SaveNetworkToDisk()
{
if(saveNetworkDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
{
MessageBox::Show("File save canceled.","Warning");
return;
}
string buf;
SystemStringToBasicString(saveNetworkDialog->FileName, buf);
ofstream(buf.c_str()) << *net;
}
//----------------------------------------------------------------------------
// Load network from disk
private: System::Void loadToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
if(openNetworkDialog->ShowDialog() != System::Windows::Forms::DialogResult::OK)
{
MessageBox::Show("File open canceled.","Warning");
return;
}
string buf;
SystemStringToBasicString(openNetworkDialog->FileName, buf);
if(net)
{
ifstream(buf.c_str()) >> *net; // overwrite the net from the file
AssignNodeLocs();
Iterations = 0L;
autocycle = true;
sw->Reset(); // because cycling will start with the next IdleAction
sw->Start();
IdleActionTimer->Start();
}
}
//----------------------------------------------------------------------------
private: System::Void indexToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show("Please navigate to this program's folder and manually launch WNEURAL.HLP.",
"Unimplemented feature");
//System::Windows::Forms::Help::ShowHelp(this,"WNEURAL.HLP",System::Windows::Forms::HelpNavigator::Index);
}
//----------------------------------------------------------------------------
}; //class
} //namespace
/* InputDialog.h 5-9-2007
This is part of the VCNeural project.
Copyright (C)2007 Steven Whitney.
Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY.
Initially published by http://25yearsofprogramming.com.
This dialog allows entry of the node counts for each layer of the neural network.
*/
#pragma once
#include <string>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace std;
namespace VCNeural {
/// <summary>
/// Summary for InputDialog
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class InputDialog : public System::Windows::Forms::Form
{
public:
InputDialog(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~InputDialog()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ Prompt;
protected:
private: System::Windows::Forms::Button^ OKButton;
private: System::Windows::Forms::Button^ cancelbutton;
public: System::Windows::Forms::NumericUpDown^ numericUpDownINPUTS;
public: System::Windows::Forms::NumericUpDown^ numericUpDownHIDDEN1;
public: System::Windows::Forms::NumericUpDown^ numericUpDownHIDDEN2;
public: System::Windows::Forms::NumericUpDown^ numericUpDownHIDDEN3;
public: System::Windows::Forms::NumericUpDown^ numericUpDownOUTPUTS;
private:
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->Prompt = (gcnew System::Windows::Forms::Label());
this->OKButton = (gcnew System::Windows::Forms::Button());
this->cancelbutton = (gcnew System::Windows::Forms::Button());
this->numericUpDownINPUTS = (gcnew System::Windows::Forms::NumericUpDown());
this->numericUpDownHIDDEN1 = (gcnew System::Windows::Forms::NumericUpDown());
this->numericUpDownHIDDEN2 = (gcnew System::Windows::Forms::NumericUpDown());
this->numericUpDownHIDDEN3 = (gcnew System::Windows::Forms::NumericUpDown());
this->numericUpDownOUTPUTS = (gcnew System::Windows::Forms::NumericUpDown());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownINPUTS))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownHIDDEN1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownHIDDEN2))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownHIDDEN3))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownOUTPUTS))->BeginInit();
this->SuspendLayout();
//
// Prompt
//
this->Prompt->AutoSize = true;
this->Prompt->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->Prompt->Location = System::Drawing::Point(12, 9);
this->Prompt->Name = L"Prompt";
this->Prompt->Size = System::Drawing::Size(202, 17);
this->Prompt->TabIndex = 12;
this->Prompt->Text = L"Enter # of nodes in each layer:";
//
// OKButton
//
this->OKButton->DialogResult = System::Windows::Forms::DialogResult::OK;
this->OKButton->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->OKButton->Location = System::Drawing::Point(128, 331);
this->OKButton->Name = L"OKButton";
this->OKButton->Size = System::Drawing::Size(114, 23);
this->OKButton->TabIndex = 10;
this->OKButton->Text = L"&OK";
this->OKButton->UseVisualStyleBackColor = true;
//
// cancelbutton
//
this->cancelbutton->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->cancelbutton->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->cancelbutton->Location = System::Drawing::Point(266, 331);
this->cancelbutton->Name = L"cancelbutton";
this->cancelbutton->Size = System::Drawing::Size(114, 23);
this->cancelbutton->TabIndex = 11;
this->cancelbutton->Text = L"&Cancel";
this->cancelbutton->UseVisualStyleBackColor = true;
//
// numericUpDownINPUTS
//
this->numericUpDownINPUTS->Location = System::Drawing::Point(132, 182);
this->numericUpDownINPUTS->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10000, 0, 0, 0});
this->numericUpDownINPUTS->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
this->numericUpDownINPUTS->Name = L"numericUpDownINPUTS";
this->numericUpDownINPUTS->Size = System::Drawing::Size(120, 20);
this->numericUpDownINPUTS->TabIndex = 1;
this->numericUpDownINPUTS->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {2, 0, 0, 0});
//
// numericUpDownHIDDEN1
//
this->numericUpDownHIDDEN1->Location = System::Drawing::Point(132, 208);
this->numericUpDownHIDDEN1->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10000, 0, 0, 0});
this->numericUpDownHIDDEN1->Name = L"numericUpDownHIDDEN1";
this->numericUpDownHIDDEN1->Size = System::Drawing::Size(120, 20);
this->numericUpDownHIDDEN1->TabIndex = 3;
this->numericUpDownHIDDEN1->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {4, 0, 0, 0});
//
// numericUpDownHIDDEN2
//
this->numericUpDownHIDDEN2->Location = System::Drawing::Point(132, 234);
this->numericUpDownHIDDEN2->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10000, 0, 0, 0});
this->numericUpDownHIDDEN2->Name = L"numericUpDownHIDDEN2";
this->numericUpDownHIDDEN2->Size = System::Drawing::Size(120, 20);
this->numericUpDownHIDDEN2->TabIndex = 5;
//
// numericUpDownHIDDEN3
//
this->numericUpDownHIDDEN3->Location = System::Drawing::Point(132, 260);
this->numericUpDownHIDDEN3->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10000, 0, 0, 0});
this->numericUpDownHIDDEN3->Name = L"numericUpDownHIDDEN3";
this->numericUpDownHIDDEN3->Size = System::Drawing::Size(120, 20);
this->numericUpDownHIDDEN3->TabIndex = 7;
//
// numericUpDownOUTPUTS
//
this->numericUpDownOUTPUTS->Location = System::Drawing::Point(132, 286);
this->numericUpDownOUTPUTS->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10000, 0, 0, 0});
this->numericUpDownOUTPUTS->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
this->numericUpDownOUTPUTS->Name = L"numericUpDownOUTPUTS";
this->numericUpDownOUTPUTS->Size = System::Drawing::Size(120, 20);
this->numericUpDownOUTPUTS->TabIndex = 9;
this->numericUpDownOUTPUTS->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(22, 182);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(46, 17);
this->label1->TabIndex = 0;
this->label1->Text = L"&Inputs";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(22, 211);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(65, 17);
this->label2->TabIndex = 2;
this->label2->Text = L"Hidden &1";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label3->Location = System::Drawing::Point(22, 234);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(65, 17);
this->label3->TabIndex = 4;
this->label3->Text = L"Hidden &2";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label4->Location = System::Drawing::Point(22, 260);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(65, 17);
this->label4->TabIndex = 6;
this->label4->Text = L"Hidden &3";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label5->Location = System::Drawing::Point(22, 286);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(58, 17);
this->label5->TabIndex = 8;
this->label5->Text = L"Ou&tputs";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label6->Location = System::Drawing::Point(12, 36);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(431, 17);
this->label6->TabIndex = 13;
this->label6->Text = L"Input (>0) Hidden1 (>=0) Hidden2 (>=0) Hidden3 (>=0) Output (>0)";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label7->Location = System::Drawing::Point(12, 64);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(409, 17);
this->label7->TabIndex = 14;
this->label7->Text = L"If any hidden layer is 0, all subsequent hidden layers must be 0.";
//
// InputDialog
//
this->AcceptButton = this->OKButton;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->CancelButton = this->cancelbutton;
this->ClientSize = System::Drawing::Size(509, 370);
this->ControlBox = false;
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->numericUpDownOUTPUTS);
this->Controls->Add(this->numericUpDownHIDDEN2);
this->Controls->Add(this->numericUpDownHIDDEN3);
this->Controls->Add(this->numericUpDownHIDDEN1);
this->Controls->Add(this->numericUpDownINPUTS);
this->Controls->Add(this->cancelbutton);
this->Controls->Add(this->OKButton);
this->Controls->Add(this->label7);
this->Controls->Add(this->label6);
this->Controls->Add(this->Prompt);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"InputDialog";
this->Text = L"Number of Nodes of to Create in each Layer";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownINPUTS))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownHIDDEN1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownHIDDEN2))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownHIDDEN3))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownOUTPUTS))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
};
}
/* PeekLevelDialog.h 5-9-2007
This is part of the VCNeural project.
Copyright (C)2007 Steven Whitney.
Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY.
Initially published by http://25yearsofprogramming.com.
This dialog allows specifying how often the graphic display is refreshed.
*/
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace VCNeural {
/// <summary>
/// Summary for PeekLevelDialog
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class PeekLevelDialog : public System::Windows::Forms::Form
{
public:
PeekLevelDialog(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~PeekLevelDialog()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Button^ button2;
public: System::Windows::Forms::NumericUpDown^ numericUpDown1;
private: System::Windows::Forms::Label^ label1;
public:
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDown1))->BeginInit();
this->SuspendLayout();
//
// button1
//
this->button1->DialogResult = System::Windows::Forms::DialogResult::OK;
this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->Location = System::Drawing::Point(86, 224);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 6;
this->button1->Text = L"&OK";
this->button1->UseVisualStyleBackColor = true;
//
// button2
//
this->button2->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button2->Location = System::Drawing::Point(228, 224);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 7;
this->button2->Text = L"&Cancel";
this->button2->UseVisualStyleBackColor = true;
//
// numericUpDown1
//
this->numericUpDown1->Location = System::Drawing::Point(148, 170);
this->numericUpDown1->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {3, 0, 0, 0});
this->numericUpDown1->Name = L"numericUpDown1";
this->numericUpDown1->Size = System::Drawing::Size(93, 22);
this->numericUpDown1->TabIndex = 5;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(15, 15);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(88, 16);
this->label1->TabIndex = 0;
this->label1->Text = L"Legal values:";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(15, 41);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(243, 16);
this->label2->TabIndex = 1;
this->label2->Text = L"0 - No graphic display (fast but invisible)";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label3->Location = System::Drawing::Point(15, 67);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(278, 16);
this->label3->TabIndex = 2;
this->label3->Text = L"1 - Once, after all Cases are finished (useless)";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label4->Location = System::Drawing::Point(15, 93);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(214, 16);
this->label4->TabIndex = 3;
this->label4->Text = L"2 - After each Case is solved (best)";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label5->Location = System::Drawing::Point(15, 119);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(173, 16);
this->label5->TabIndex = 4;
this->label5->Text = L"3 - After each iteration (slow)";
//
// PeekLevelDialog
//
this->AcceptButton = this->button1;
this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->CancelButton = this->button2;
this->ClientSize = System::Drawing::Size(389, 271);
this->ControlBox = false;
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->numericUpDown1);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
this->Margin = System::Windows::Forms::Padding(4);
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"PeekLevelDialog";
this->Text = L"Set graphic display update frequency";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDown1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
};
}
The next page (VCPPNetwork.cpp) has the classes that implement the neural network.
|
|
|
|
|
|