【轉】 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.
複製代碼


發佈了18 篇原創文章 · 獲贊 14 · 訪問量 16萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章