Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Neural Dot Net Pt 3 The Adaline Network

, 23 Oct 2003
A neural network library in C#.
neural_dot_net_2002.zip
Neural Dot Net 2002
App.ico
bin
Debug
AdalineWordFile.dat
adalinewordWorkingFile.wrk
adword.trn
App.ico
BackpropagationWorkingFile.wrk
Lin2Var.trn
Neural Dot Net 2002.exe
Neural Net Library.dll
SelfOrganizingNetworkOne.trn
SelfOrganizingNetworkOne.wrk
SelfOrganizingNetworkOneTest.tst
SharpUtils.dll
SharpUtils.pdb
equations.Bak
Neural Dot Net 2002.csproj.user
Neural Net Library
bin
Debug
Neural Net Library.csproj.user
Neural Net Library.suo
obj
Debug
Neural Net Library.projdata
temp
TempPE
SharpUtils
bin
Debug
obj
Debug
SharpUtils.projdata
temp
TempPE
SharpUtils.csproj.user
SharpUtils.suo
neural_network_first_release.zip
Neural Network First release
3e5b39da.jpg
3e5b3ee8.jpg
3e65d686.jpg
3e65d687.jpg
Adaline.png
AdalineOneOptions.png
AdalineTwoOptions.jpg
AdalineWordClassDiagram.png
Adalinewordpattern.png
Addwordtoadalinetwofile.png
Backpropagationclasses.png
BackPropagationOneDiagram.png
backpropagationoneoptions.png
BackPropagationWordDiagram.png
BackPropagationWordOptions.png
BackPropagationWordPattern.png
Basic.png
BasicLinkWorks.png
BasicNetworkTester Overview.png
BasicNeuronComponent.png
changedBasicClassDiagram.png
equationTest.jpg
equationwithbias.jpg
function.jpg
Generating a given File.png
Inside Adaline Transition Function.png
Inside Self Organizing network run.png
Inside The Adaline Run Function Plus Bias.png
Inside The Adaline Run Function.png
learn For the self organizing network.png
Learning For the Backpropagation Network.png
LogViewer
LogViewer.csproj.user
Neural Net Library
Adaline.png
Adalinewordpattern.png
BackPropagation.emf
Basic.png
librarytobackprop.png
Neural Net Library.csproj.user
Pattern.png
Thumbs.db
Neural Net Test
App.ico
bin
Debug
AdalineWordFile.dat
adalinewordWorkingFile.wrk
adword.trn
AxInterop.SHDocVw.dll
BackpropagationWorkingFile.wrk
Interop.SHDocVw.dll
Lin2Var.trn
LogViewer.dll
Neural Net Library.dll
Neural Net Test.exe
SelfOrganizingNetworkOne.trn
SelfOrganizingNetworkOne.wrk
SelfOrganizingNetworkOneTest.tst
SharpUtils.dll
Neural Net Test.csproj.user
NeuralNetTesterPackages.png
Pattern.png
SelfOrganizingNetworkDiagram.png
SelfOrganizingNetworkOneClasses.png
selfOrganizingnetworkoneoptions.png
SelfOrganizingNetworkTwoOptions.png
selforganizingnetworkword.png
Setting Options For a Given Network.png
SharpUtils
SharpUtils.csproj.user
Testing a Given Network.png
Thumbs.db
Train Network Interaction.png
Training a given Network.png
TransferEq.jpg
TransferFunctionlogic.jpg
Transferfunctionwithbias.jpg

using System;
using System.Collections;
using SharpUtils;
using System.Xml.Serialization;

namespace Neural_Net_Library
{
	/// <summary>
	/// Summary description for Pattern.
	/// </summary>
	public class Pattern
	{
		private ArrayList arrayInSet;
		private ArrayList arrayOutSet;
		private static int nPatternID = 0;
		private int nCurrentID;


		private DebugLevel debugLevel;
		private Logger log;

		/// <summary>
		/// get the in set array
		/// </summary>
		public ArrayList InSet
		{
			get
			{
				return arrayInSet;
			}
		}

		/// <summary>
		/// get the out set array
		/// </summary>
		public ArrayList OutSet
		{
			get
			{
				return arrayOutSet;
			}
		}

		/// <summary>
		/// get the pattern id
		/// </summary>
		public int PatternID
		{
			get
			{
				return nCurrentID;
			}
		}

		/// <summary>
		/// base constructor
		/// </summary>
		public Pattern( Logger log )
		{


			arrayInSet = new ArrayList();
			arrayOutSet = new ArrayList();
			nPatternID++;
			nCurrentID = nPatternID;

			debugLevel = new DebugLevel( DebugLevel.currentLevel );
			this.log = log;
		}

		/// <summary>
		/// constructor taking the array sizes
		/// </summary>
		/// <param name="nInSize"></param>
		/// <param name="nOutSize"></param>
		public Pattern( Logger log, int nInSize, int nOutSize )
		{
			arrayInSet = new ArrayList( nInSize );
			for( int i=0; i<nInSize; i++ )
				arrayInSet.Add( 0.0 );
			arrayOutSet = new ArrayList( nOutSize );
			for( int i=0; i<nOutSize; i++ )
				arrayOutSet.Add( 0.0 );
			nPatternID++;
			nCurrentID = nPatternID;

			debugLevel = new DebugLevel( DebugLevel.currentLevel );
			this.log = log;
		}

		/// <summary>
		/// constructor taking array lists
		/// </summary>
		/// <param name="arrayInSet"></param>
		/// <param name="arrayOutSet"></param>
		public Pattern( Logger log, ArrayList arrayInSet, ArrayList arrayOutSet )
		{
			arrayInSet = arrayInSet;
			arrayOutSet = arrayOutSet;
			nPatternID++;
			nCurrentID = nPatternID;

			debugLevel = new DebugLevel( DebugLevel.currentLevel );
			this.log = log;
		}


		public Pattern( Logger log, double inputOne, double inputTwo, double output )
		{
			debugLevel = new DebugLevel( DebugLevel.currentLevel );
			this.log = log;

			arrayInSet = new ArrayList();
			arrayInSet.Add( inputOne );
			arrayInSet.Add( inputTwo );
			arrayOutSet = new ArrayList();
			arrayOutSet.Add( output );

			nPatternID++;
			nCurrentID = nPatternID;

		}

		/// <summary>
		/// save the pattern
		/// </summary>
		public virtual void Save()
		{
			if( debugLevel.TestDebugLevel( DebugLevelSet.Progress ) == true )
			{
				log.Log( DebugLevelSet.Progress, "Save called on Pattern", ClassName );
			}
		
		}

		/// <summary>
		/// load the pattern
		/// </summary>
		public virtual void Load()
		{
			if( debugLevel.TestDebugLevel( DebugLevelSet.Progress ) == true )
			{
				log.Log( DebugLevelSet.Progress, "Load called on pattern", ClassName );
			}
		}

		/// <summary>
		/// make a copy of the pattern
		/// </summary>
		/// <param name="pattern"></param>
		public void Copy( Pattern pattern )
		{
			if( debugLevel.TestDebugLevel( DebugLevelSet.Progress ) == true )
			{
				log.Log( DebugLevelSet.Progress, "Copying the pattern", ClassName );
			}

			arrayInSet = ( ArrayList )pattern.InSet.Clone();
			arrayOutSet = ( ArrayList )pattern.OutSet.Clone();
			nPatternID = pattern.PatternID;
		}


		/// <summary>
		/// set the input value
		/// </summary>
		/// <param name="nIndex"></param>
		/// <param name="dValue"></param>
		public void SetInValue( int nIndex, double dValue )
		{
			if( debugLevel.TestDebugLevel( DebugLevelSet.Progress ) == true )
			{
				log.Log( DebugLevelSet.Progress, "setting the input value at " + nIndex.ToString() + " to " + dValue.ToString(), ClassName );
			}

			try
			{
				arrayInSet[ nIndex ] = dValue;
			}
			catch( ArgumentOutOfRangeException argorExp )
			{
				arrayInSet.Add( dValue );
				if( debugLevel.TestDebugLevel( DebugLevelSet.Warning ) == true )
				{
					log.Log( DebugLevelSet.Warning, "The index the array in set in value is greater than the array count, adding it, reason " + argorExp.Message, ClassName );
				}
			}
		}


		/// <summary>
		/// set the output value
		/// </summary>
		/// <param name="nIndex"></param>
		/// <param name="dValue"></param>
		public void SetOutValue( int nIndex, double dValue )
		{
			if( debugLevel.TestDebugLevel( DebugLevelSet.Progress ) == true )
			{
				log.Log( DebugLevelSet.Progress, "Setting the out value at " + nIndex.ToString() + " to " + dValue.ToString(), ClassName );
			}

			try
			{
				arrayOutSet[ nIndex ] = dValue;
			}
			catch( ArgumentOutOfRangeException argorExp )
			{
				arrayOutSet.Add( dValue );
				if( debugLevel.TestDebugLevel( DebugLevelSet.Warning ) == true )
				{
					log.Log( DebugLevelSet.Warning, "The index for the array set out value is greater than the array count, adding it, reason " + argorExp.Message, ClassName );
				}
			}
		}

		/// <summary>
		/// get the input value at the given index
		/// </summary>
		/// <param name="nIndex"></param>
		/// <returns></returns>
		public double InputValue( int nIndex )
		{
			if( debugLevel.TestDebugLevel( DebugLevelSet.Progress ) == true )
			{
				log.Log( DebugLevelSet.Progress, "Getting the input value at " + nIndex.ToString(), ClassName );
			}

			if( nIndex < arrayInSet.Count )
				return ( double )arrayInSet[ nIndex ];
			else
			{
				if( debugLevel.TestDebugLevel( DebugLevelSet.Warning ) == true )
				{
					log.Log( DebugLevelSet.Warning, "The index value to get the input value is greater than the array count", ClassName );
				}

				return 0.0;
			}
		}

		/// <summary>
		/// get the output value at the given index
		/// </summary>
		/// <param name="nIndex"></param>
		/// <returns></returns>
		public double OutputValue( int nIndex )
		{
			if( debugLevel.TestDebugLevel( DebugLevelSet.Progress ) == true )
			{
				log.Log( DebugLevelSet.Progress, "Getting the output value at " + nIndex.ToString(), ClassName );
			}

			if( nIndex < arrayOutSet.Count )
				return ( double )arrayOutSet[ nIndex ];
			else
			{
				if( debugLevel.TestDebugLevel( DebugLevelSet.Warning ) == true )
				{
					log.Log( DebugLevelSet.Warning, "the index value to get the output value is greater than the array count", ClassName );
				}

				return 0.0;
			}
		}

		public int InputSize()
		{
			return arrayInSet.Count;
		}

		public int OutputSize()
		{
			return arrayOutSet.Count;
		}


		public string ClassName
		{
			get
			{
				return this.ToString();
			}
		}
			
	}
}

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 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

Share

About the Author

pseudonym67

United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.141022.1 | Last Updated 24 Oct 2003
Article Copyright 2003 by pseudonym67
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid