【转】 Matlab神经网络工具箱中的Train和Adapt函数区别


转至: http://www.matlabsky.com/thread-4084-1-1.html


先看看Matlab官方的解释,请如下操作:

在Matlab的Command Window中输入doc adapt或者doc train,将滚动条拖到最后有一个Algorithm说明,这里有两个函数的计算介绍。

adapt
  1. adapt calls the function indicated by net.adaptFcn, using the adaption parameter values indicated by net.adaptParam.

  2. Given an input sequence with TS steps, the network is updated as follows: Each step in the sequence of inputs is presented to the network one at a time. The network's weight and bias values are updated after each step, before the next step in the sequence is presented. Thus the network is updated TS times.

  3. 这就是说,输入输出样本对是按照TS时间延迟来一个一个逐步“调整”网络的权系值的。每给网络一个样本,网络就根据这个样本数据更新一次,如果有N个样本,那网络就更新N次。当然,也可以使网络在输入完所有样本后,再重新将该样本集输入给网络。输入一次样本集(sequence of inputs),就称为一个"pass"。其中,样本集的个数应该等于TS,即前面提到的N=TS。
复制代码
train
  1. train calls the function indicated by net.trainFcn, using the training parameter values indicated by net.trainParam.

  2. Typically one epoch of training is defined as a single presentation of all input vectors to the network. The network is then updated according to the results of all those presentations.

  3. Training occurs until a maximum number of epochs occurs, the performance goal is met, or any other stopping condition of the function net.trainFcn occurs.

  4. Some training functions depart from this norm by presenting only one input vector (or sequence) each epoch. An input vector (or sequence) is chosen randomly each epoch from concurrent input vectors (or sequences). newc and newsom return networks that use trainr, a training function that does this.

  5. 这就是说,所有的训练样本都参与了训练过程,即使网络只迭代一次。训练(train)是根据性能函数(或者叫做误差函数)来对权系值的矩阵进行迭代,但调整(adapt)则没有这样的性能函数,仅给了一个误差值。
复制代码
我们再看一个Matlab帮助系统自带的解释
  1. One kind of general learning function is a network training function. Training functions repeatedly apply a set of input vectors to a network, updating the network each time, until some stopping criteria is met. Stopping criteria can consists of a maximum number of epochs, a minimum error gradient, an error goal, etc.

  2. The other kind of the general learning function is a netowrk adapt function. Adapt functions simulate a network, while updating the network for each time step of the input before continuing the simulation to the next input.
复制代码
matlab中神经网络的训练分为批训练(batch training)和增长训练(incremental training)。
其中如果用train来训练网络则是批训练,而adapt既可以实现批训练,也可以实现增长训练,主要取决于神经网络的输入形式是并行输入(concurrent inputs)还是串行输入(sequential inputs),如果是前者则实现批训练,如果后者则是增长训练。

所谓批训练是指当全部输入都输入神经网络后,其权值和阀值才更新一次。而增长训练是指每输入一个输入,权值和阀值就更新一次。

所谓并行输入,其格式是用数组[]的形式来表示。即[1 2,3 4]这个就是并行输入,其输入不分先后。而串行输入则是用细胞数组{}来表示,如{[1;3],[2;4]},其输入有先后顺序

换句话说,到底是串行还是并行,不是通过神经网络的某个参数来决定的,而是看输入样本的格式(“[]”还是“{}”)。

但是对于train()而言,即使你的输入是串行输入,它也许自动把该输入转化为并行输入进行批训练。简单而言,train只能用于批训练。而adapt两者都可以(批训练或者增长训练),如何进行就看输入形式。不是通过参数来规定串行还是并行,而是通过输入的形式是同时输入还是顺序输入来决定的。但是对于train方法而言,即使你的输入是顺序输入,它也许自动把该输入转化为同时输入进行批训练。简单而言,train只能用于批训练。


比如说,训练样本有100个
1.train:在这100个样本一次性掉入进行网络计算后,对网络参数进行一次调整。
2.adapt:如果[]输入,这和train相当;如果{}输入,则样本一个一个输入,每输入一个样本数据进行一次计算,然后对网络参数进行一次调整,所以共要调整100次。

需要注意的一点是,不是所有的训练函数和学习函数都支持增长训练(incremental training)

最后再看一个官方说明
  1. adapt/train's signal arguments can have two formats: cell array or matrix.

  2. The cell array format is easiest to describe. It is most convenient for networks with multiple inputs and outputs, and allows sequences of inputs to be presented.

  3. The matrix format can be used if only one time step is to be simulated (TS = 1). It is convenient for networks with only one input and output, but can be used with networks that have more.
复制代码


展开阅读全文

没有更多推荐了,返回首页