如何使用 Ruby 的 ai4r gem 将神经网络保存到文件中?

发布于 2024-08-28 08:31:57 字数 326 浏览 1 评论 0原文

我正在使用 ruby​​ 的 ai4r gem 构建神经网络。 gem 的 1.1 版本允许我简单地对文件执行 Marshal.dump(network),并且我可以随时加载网络备份。

几年后的 1.9 版本中,我无法再这样做了。当我尝试时,它会生成此错误:

no marshal_dump is defined for class Proc

我知道错误的原因 - Marshal 无法处理对象中的过程。很公平。

那么ai4r中有内置的东西吗?我一直在寻找但没有运气。我无法想象神经网络有什么实际用途,每次你想使用它时都必须从头开始重建。

I'm using ruby's ai4r gem, building a neural network. Version 1.1 of the gem allowed me to simply do a Marshal.dump(network) to a file, and I could load the network back up whenever I wanted.

With version 1.9 a couple years later, I'm no longer able to do this. It generates this error when I try:

no marshal_dump is defined for class Proc

I know the reason for the error - Marshal can't handle procs in an object. Fair enough.

So is there something built in to ai4r? I've been searching with no luck. I can't imagine any practical use for a neural network you have to rebuild from scratch every time you want to use it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪痕残 2024-09-04 08:31:57

我刚刚解决了这个问题。 1.10 版本应该可以正常工作。

但是,如果您使用 lambda 函数自定义传播函数,则必须在加载实例后手动恢复它。
这是因为 lambda 函数无法序列化,因此实现将其重置为默认函数。
很抱歉没有早点解决这个问题,但我已经度过了疯狂的几个月工作。

干杯,

塞尔吉奥·菲伦斯。

I just fixed that problem. Version 1.10 should work OK.

However, if you customize the propagation function with a lambda function, you will have to restore it manually after loading the instance.
This is because lambda functions cannot be serialized, so the implementation reset it to the default function.
Sorry for not solving it sooner, but I have been having some crazy months at work.

Cheers,

Sergio Fierens.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文