如何在Matlab中逐步训练神经网络? [英] How to train neural network incrementally in Matlab?

查看:809
本文介绍了如何在Matlab中逐步训练神经网络?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的火车非常大,以至于Matlab在训练时挂起,或者没有足够的内存来容纳火车.

Suppose I have very big train set so that Matlab hangs while training or there is insufficient memory to hold train set.

是否可以将训练集分成多个部分并按部分训练网络?

Is it possible to split the training set into parts and train the network by parts?

是否可以一次(一个接一个)地训练一个样本的网络?

Is it possible to train the network with one sample at a time (one by one)?

推荐答案

您可以手动将数据集分为几批,然后一一训练:

You can just manually divide dataset into batches and train them one after one:

for bn = 1:num_batches
    inputs = <get batch bn inputs>;
    targets = <get batch bn targets>;
    net = train(net, inputs, targets);
end

尽管批处理大小应大于1,但无论如何应减少训练的内存消耗.

Though batch size should be greater than 1, but anyway that should reduce memory consumtion for training.

如果trainlm训练算法,net.efficiency.memoryReduction优化可能会有所帮助. 另外,您可以尝试使用更少的内存消耗(例如trainrp)来代替默认的trainlm算法. 有关训练算法的详细信息,请查看 matlab文档页面. 上面我假设您正在使用用于神经网络的相应的matlab工具箱.

In case of trainlm training alogrithm, net.efficiency.memoryReduction optim could help. Also instead of default trainlm algorithm you can try less memory consuming ones like trainrp. For details on training algorithms check matlab documentation page. I assumed above that you are using corresponding matlab toolbox for neural networks.

关于一次训练一个样本,您可以尝试使用谷歌搜索随机梯度下降算法.但是,它似乎不在工具箱的默认训练算法集中.

Regarding training one sample at a time you could try googling for stochastic gradient descent algorithm. But, it looks like it is not in default set of training algorithm in the toolbox.

这篇关于如何在Matlab中逐步训练神经网络?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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