Click here to Skip to main content
15,886,045 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hey Guys,

I am building a neural network application to test some of my limited skills in c# :p Built my own classes etc... I have currently done some test networks by hand making an AND gate with hand written network statements.

Array declaration for AND gate
Neuron[,] NodeList = new Neuron[2, 2];  //For AND gate sample

//Some code that runs other functions etc
NodeList[0, 0].Link(NodeList[1, 0], 1);
NodeList[0, 1].Link(NodeList[1, 0], 1);
NodeList[1, 0].Threshold = 1.5f;

//Run Network
RunStandardFire();

//Show output
MessageBox.Show(LastLayerOutput[0].ToString());


This above example works fine



However now I am moving onto a huge neuron bank that will have its links generated at random as all small scale tests seem to work.
Neuron[,] NodeList = new Neuron[2000000, 50000];

The above line has a hissy fit and has an out of memory exception. As far as I know windows does memory allocation of 1.5GB~2GB (I think).

After searching the internet I can only find people explaining the situation. How can I increase the memory space my application is allowed to use?

Thank you to all in advance :)
Posted

Don't use C#.

Simple as that.
Even if a Neuron occupied only 1 byte, you would be allocating 100,000,000,000 bytes: 100 Gigabyte.

If you must do this, find a file system that supports (100 * the size of a Neuron) Gigabyte files - NTFS should be able to cope - and do your own memory mapping: you won't be able to do it via C# unless the NT framework under x64 uses Int64 for all the file access routines - I don't know. Set up a huge file, and treat that as your memory area. You might as well, unless you can physically get maybe a terabyte of RAM into your system most of any memory you could allocate would be paged out all the time anyway.
 
Share this answer
 
Comments
Thomas.D Williams 5-May-11 14:57pm    
Haha :) I don't have that much RAM. I am currently running Win 7 64bit. I may have to use a clever way of writing to and from files. I have 1TB Hard Disk space so that wouldn't be an issue. Thank you for the feedback :)
OriginalGriff 5-May-11 15:02pm    
It's not the hard disk space that's the issue: it's if you can address it from within the .NET framework. An int is still int32 even under x64, and that is all the space you have for File.Seek parameters!
NuttingCDEF 5-May-11 15:56pm    
Totally agree - my 5 - so if you need something bigger, you might need a class that looks like a big address space from the outside, but inside stores its data in multiple files of sizes that don't cause addressing problems. Should be a fun one to write!
Thomas.D Williams 5-May-11 15:15pm    
I have decided to compromise at a mere 40,000,000 neurons. Even then it took 5mins to run through that network once :)
OriginalGriff 5-May-11 15:21pm    
So, you won't be building Skynet any time soon, then? :laugh:
You can't use more memory than what's in the box (counting virtual memory).
 
Share this answer
 
Comments
Thomas.D Williams 5-May-11 14:58pm    
Thank you for the feedback :) I'm going to have a go with smaller networks :p
Going with the previous 2 answers I have resolved that unless I use some clever file writing for the network it is unfeasable to get an array that big.
Neurons in animal brains

A reasonable size array was of size 10000*4000 size array producing a sizeable 1GB in windows resource manager.
Looking at the link above you can clearly see the 40,000,000 neurons my program has puts it somewhere in between a rat and a dog :) (Once trained obviously)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900