简体   繁体   English

学习算法与软件保存数据

[英]Learning Algorithm and Saving Data in Software

I'm coming from a web-development background and I am wondering how I would make a learning algorithm in Java/C++. 我来自网络开发背景,我想知道如何在Java / C ++中创建学习算法。 Not so much the algorithm part, but making the program "remember" what it learned from the previous day. 与算法部分不同,但让程序“记住”从前一天学到的东西。 I would think something like saving a file, but I suspect their might be an easier way. 我会想像保存文件一样,但我怀疑它们可能更简单。 Apologies if this question is just over the top stupid. 如果这个问题刚刚超过最愚蠢,请道歉。 Thanks. 谢谢。

I think that would depend a bit on the problem domain. 我认为这将取决于问题领域。 You might want to store learned "facts" or "relationships" in a DB so that they can be easily searched. 您可能希望在数据库中存储已学习的“事实”或“关系”,以便可以轻松搜索它们。 If you are training a neural network, then you'd probably just dump the network state to a file. 如果您正在训练神经网络,那么您可能只是将网络状态转储到文件中。 In general, I think once you have a mechanism that does the learning, the appropriate storage representation will be relatively apparent. 一般来说,我认为一旦你有一个学习机制,适当的存储表示将是相对明显的。

Maybe if you can flesh out your plan on what kind of learning you'd like to implement, people can provide more guidance on what the implementation should look like, including the state storage. 也许如果你可以充实你想要实现什么样的学习的计划,人们可以提供更多关于实现应该是什么样子的指导,包括状态存储。

Not stupid, but a little ill-formed maybe. 不是傻瓜,但可能有点不合理。

What you're going to do as your program "learns" something is update the state of some data structure. 当您的程序“学习”某事时,您将要做的是更新某些数据结构的状态。 If you want to retain that state, you need to persist the data structure to some external store. 如果要保留该状态,则需要将数据结构保留到某个外部存储。 That means translating the data structure to some external formal that you can read back in without loss. 这意味着将数据结构转换为一些您可以无损失地读回的外部形式。

Java provides a straightforward way to do this via the Serializable interface; Java通过Serializable接口提供了一种直接的方法; you Serialize the data by sending Serializable ojects out through an ObjectStream; 您通过ObjectStream发送Serializable对象来序列化数据; the same ObjectStream will reload them later. 相同的ObjectStream稍后会重新加载它们。

If you want to access and save large amounts of data maybe a database would work well. 如果您想访问并保存大量数据,那么数据库可能会运行良好。 This would allow you to structure the data and look it up in an easier manner. 这将允许您构建数据并以更简单的方式查找它。 I'm not too well versed on the subject but I think for remembering and recalling things a database would be vastly superior to a file system. 我对这个主题并不太熟悉,但我认为记住和回忆一下数据库会远远优于文件系统。

A robust/flexible solution in Java (C++ too, but I wouldn't know how) would be using a database. Java中一个强大/灵活的解决方案(C ++,但我不知道如何)将使用数据库。 Java 1.6 comes with the Apache derby database which can be embedded in your apps. Java 1.6附带了Apache derby数据库,可以嵌入到您的应用程序中。 Using JPA (Java Persistence API) makes it easy to interface with any database you can find drivers for. 使用JPA(Java Persistence API)可以轻松地与您可以找到驱动程序的任何数据库进行交互。

You should look into Neural Network software development . 您应该研究神经网络软件开发 Here's a collection of nice Neural Network libraries for different languages. 这里有一组用于不同语言的不错的神经网络库。 I am not sure if this is the easy way but once accomplished would be very handy. 我不确定这是否是简单的方法,但一旦完成将非常方便。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM