保存具有所有值的对象(即经过训练的神经网络) [英] saving an object with all its values (i.e. trained neural networks)

查看:69
本文介绍了保存具有所有值的对象(即经过训练的神经网络)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有保存对象的一般方法?具体来说,我正在使用Aforge DLL在C#中实现神经网络.但是,我没有看到有关如何保存经过训练的神经网络的任何文档,因此我想知道是否存在一种通用的方法可以保存网络以供以后使用而无需每次都对其进行重新培训.

Is there a general way to save an object? Specifically, I am using the Aforge DLL to implement neural networks in C#. However I don''t see any documentation on how to save a trained neural network so I was wondering if there may be a general way of saving the network to use it later without having to retrain it every time.

推荐答案

除了Mika建议的BinaryFormatter类外,还抢劫了 Data Contract .它使您不仅可以存储/加载对象,还可以存储/加载不必是树(层次结构)的任意对象图.而且,此方法是非常非侵入性的:您不必以任何方式修改数据类型,甚至不必访问修饰符.您要做的就是向类型和成员添加属性.同样,您可以为数据与新版本应用程序的备份兼容性做出非常可靠的规定.

参见:
http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

另请参阅我过去的答案,其中我主张采用这种出色的方法:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [反序列化json字符串数组 [
In addition to the BinaryFormatter class advised by Mika, loot at Data Contract. It allows you to store/load not just an object but an arbitrary object graph which does not have to be a tree (hierarchical). Also, this method is very non-intrusive: you don''t have to modify your data types in any way, not even access modifiers. All you do is adding attributes to types and members. Also, you can make a very reliable provisions for backup compatibility of your data with newer versions of the applications.

See:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

See also my past answers where I advocate this wonderful approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^],
deseralize a json string array[^].

—SA


根据保存文件的类型,保存对象的机制可能会有所不同.看看 BinaryFormatter类 [ ^ ].
Depending on the type of the saved file the mechanism to save an object may vary. Have a look at BinaryFormatter Class[^] for example.


这篇关于保存具有所有值的对象(即经过训练的神经网络)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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