C#中的神经网络内存异常 [英] Neural Networks memory exceptions in c#

查看:73
本文介绍了C#中的神经网络内存异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在构建一个神经网络应用程序,以测试我在c#中有限的一些技能:p建立了自己的类,等等...目前,我已经通过手工编写带有与网络声明的AND门来完成一些测试网络.

AND门的数组声明

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


上面的代码有些古怪,并且内存不足.据我所知,Windows可以分配1.5GB〜2GB的内存(我认为).

搜索互联网后,我只能找到解释情况的人.如何增加允许我的应用程序使用的内存空间?

提前谢谢大家:)


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

推荐答案

不要使用C#.

就这么简单.
即使神经元仅占用1个字节,您也将分配100,000,000,000个字节:100 GB.

如果必须执行此操作,请找到一个文件系统,该文件系统支持(100 * Neuron大小)千兆字节文件-NTFS应该能够应对-并执行您自己的内存映射:您将无法通过C#做到这一点除非x64下的NT框架将Int64用于所有文件访问例程-我不知道.设置一个大文件,并将其视为您的内存区域.您也可能会这样做,除非您可以在系统中物理地获得1 TB的RAM,否则您可以分配的所有内存中的大部分都会始终被调出.
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.


您不能使用比方框中更多的内存(计算虚拟内存).
You can''t use more memory than what''s in the box (counting virtual memory).


使用前面的2个答案,我解决了以下问题:除非我为网络使用一些巧妙的文件写入功能,否则无法获得如此大的数组.
动物脑中的神经元

一个合理大小的数组的大小为10000 * 4000大小,在Windows资源管理器中产生了1GB的大小.
通过上面的链接,您可以清楚地看到我的程序将40,000,000个神经元放在了老鼠和狗之间的某个位置:)(显然,一旦经过训练)
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)


这篇关于C#中的神经网络内存异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆