1. 程式人生 > >【讀書1】【2017】MATLAB與深度學習——二元分類(1)

【讀書1】【2017】MATLAB與深度學習——二元分類(1)

在這裡插入圖片描述
圖4-2 二元分類的訓練資料格式Training data binaryclassification

圖中的前兩個數字分別表示x和y座標,符號表示該資料所屬的類別。

The first two numbers indicate the x and ycoordinates respectively, and the symbol represents the group in which the databelongs.

訓練資料包括輸入和正確的輸出,因為這些資料被用於監督學習。

The data consists of the input and correctoutput as it is used for supervised learning.

現在,讓我們構造神經網路。

Now, let’s construct the neural network.

輸入節點的數目等於輸入引數的數目。

The number of input nodes equals the numberof input parameters.

由於本示例的輸入由x和y兩個引數組成,因此網路採用兩個輸入節點。

As the input of this example consists oftwo parameters, the network employs two input nodes.

我們需要一個輸出節點,因為要將輸入資料分為兩類。

We need one output node because thisimplements the classification of two groups as previously addressed.

採用sigmoid函式作為啟用函式,隱藏層具有四個節點。

The sigmoid function is used as theactivation function, and the hidden layer has four nodes.

隱藏層不是我們關心的內容。

The hidden layer is not our concern.

根據分類數量變化的層是輸出層,而不是隱藏層。

The layer that varies depending on thenumber of classes is the output layer, not the hidden layer.

隱藏層的組成沒有標準規則,這裡選擇4個節點只是基於經驗的規則。(但值得注意的是:隱藏層越複雜,神經網路的運算量越大,但是學習速度可能會越快,各項效能指標也會更好,因此在實際的設計中,一項優秀的設計應當是複雜度與效能之間的最佳折中;如同買一件衣服,最好的衣服可以無窮貴,但對於每個人來說,我們只需要買最合適的衣服,而不是最好的衣服)

There is no standard rule for thecomposition of the hidden layer.

圖4-3示出了以上描述的神經網路。

Figure 4-3 shows the described neuralnetwork.

在這裡插入圖片描述
圖4-3 訓練資料的神經網路Neural network for thetraining data

當我們用給定的訓練資料訓練這個網路時,我們可以得到我們想要的二元分類。

When we train this network with the giventraining data, we can get the binary classification that we want.

然而,存在一個問題。

However, there is a problem.

神經網路產生範圍從0 - 1的數值輸出,而最終的資料分類結果只劃分為兩類,即△和●。

The neural network produces numericaloutputs that range from 0-1, while we have the symbolic correct outputs givenas △ and ●.

我們不能用這種方式計算誤差,我們需要把符號轉換成數字程式碼。

We cannot calculate the error in this way;we need to switch the symbols to numerical codes.

我們可以將sigmoid函式的最大值和最小值分配給如下兩類符號:

We can assign the maximum and minimumvalues of the sigmoid function to the two classes as follows:
在這裡插入圖片描述

符號表示的變化產生如圖4-4所示的訓練資料。

The change of the class symbols yields thetraining data shown in Figure 4-4.

——本文譯自Phil Kim所著的《Matlab Deep Learning》

更多精彩文章請關注微訊號:在這裡插入圖片描述