1 / 47

Chapter 3

Chapter 3. Multilayer Feedforward Networks. Multilayer Feedforward Network Structure. Output nodes. Layer N. Layer N-1. Hidden nodes. Layer 1. Connections. Input nodes. Layer 0. N -layer network. Input node. h = layer no. Hidden node. Output node. i = node i of layer h.

tia
Télécharger la présentation

Chapter 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 3 Multilayer Feedforward Networks

  2. Multilayer Feedforward Network Structure Output nodes Layer N Layer N-1 Hidden nodes Layer 1 Connections Input nodes Layer 0 N-layer network

  3. Input node h = layer no. Hidden node Output node i = node i of layer h h = layer no. j = node j of layer h-1 i = node i of layer h Multilayer Feedforward Network Structure (cont.) x1 o1 x2 x3 Output ของแต่ละโหนด โดย

  4. h = Pattern No. h = layer no. i = node i of layer h i = node i of layer h Multilayer Feedforward Network Structure (cont.) หมายเหตุ: การเขียน superscript index ในหนังสือส่วนใหญ่จะใช้ในความหมายนี้ Superscript index ในเอกสารชุดนี้จะใช้แบบข้างล่างแทน

  5. Multilayer Perceptron : How it works Function XOR y1 x1 o x2 y2 Layer 1 Layer 2 f( ) = step function

  6. (1,1) (0,1) x2 (0,0) (1,0) x1 Multilayer Perceptron : How it works (cont.) Outputs at layer 1 y1 x1 x2 y2

  7. y1-y2 space x1-x2 space (1,1) (0,1) x2 y2 (0,0) (1,0) x1 y1 Class 1 Class 0 Multilayer Perceptron : How it works (cont.) Inside layer 1 (1,1) Linearly separable ! (0,0) (1,0)

  8. (1,1) y1-y2 space y2 (0,0) (1,0) y1 Class 0 Class 1 Multilayer Perceptron : How it works (cont.) Inside output layer y1 o y2 Space y1-y2เป็น linearly separable ดังนั้นเราใช้เส้นตรงL3แบ่ง class 0 กับ class 1ได้

  9. Multilayer Perceptron : How it works (cont.) • การทำงานของ hidden layers • พยายามจะแปลงข้อมูลที่เข้ามาที่ layer นั้นๆให้เป็น linearly separable • ก่อนที่ข้อมูลจะถูกส่งไปถึง output layer • ในขั้นตอนสุดท้ายที่ Hidden layer, ข้อมูลต้องเป็น linearly separable • อาจจะต้องใช้ hidden layer มากกว่า 1 layer ในการแปลงข้อมูลให้อยู่ใน • รูป linearly separable • โดยทั่วไป Activation function ของแต่ละ layer ไม่จำเป็นต้องเป็น • Thresholding function และไม่จำเป็นต้องเป็น function เดียวกัน

  10. Backpropagation Algorithm 2-Layer case Output layer Hidden layer Input layer

  11. Backpropagation Algorithm (cont.) 2-Layer case หาอนุพันธ์ของ e2เทียบกับ w(2)k,j หาอนุพันธ์ของ e2เทียบกับ q (2)k

  12. Backpropagation Algorithm (cont.) 2-Layer case หาอนุพันธ์ของ e2เทียบกับ w(1)j,i

  13. Backpropagation Algorithm (cont.) ตอนนี้เราหาอนุพันธ์ของ e2เทียบกับ w(1)j,i เพื่อใช้ในการปรับ weight ที่เชื่อมระหว่าง Node j ของ current layer (Layer 1)กับ Node i ของ Lower Layer (Layer0) Weight between upper Node k and Node j of current layer Error from upper Node k Derivative of upper Node k Input from lower Node i Derivative of Node j of current layer ส่วนนี้คือ Error ที่ส่งผ่านกลับ (back propagation) มายัง Node j ที่ current layer

  14. Backpropagation Algorithm (cont.) เปรียบเทียบ อนุพันธ์ของ e2 เทียบกับ w(2)k,j Derivative of current node Input from lower node Error at current node อนุพันธ์ของ e2 เทียบกับ w(1)j,i โดยทั่วไป อนุพันธ์ของ error เทียบกับ weight ที่เชื่อมระหว่าง 2 layer ที่ติดกัน จะมีรูปแบบเหมือนกัน คือเป็นผลคูณระหว่าง error,derivative และ input

  15. Backpropagation Algorithm (cont.) General case อนุพันธ์ของ e2เทียบกับ weight ที่เชื่อมระหว่าง Node j ใน Layer n (current layer) กับ Node iใน Layer n-1 (lower layer) Input from Node i of lower layer Weighted input sum at Node j Error at Node j of Layer n Derivative of Node j

  16. Backpropagation Algorithm (cont.) General case อนุพันธ์ของ e2เทียบกับ bias(q) ภายใน Node j ใน Layer n (current layer) Weighted input sum at Node j Error at Node j of Layer n Derivative of Node j

  17. Backpropagation Algorithm (cont.) General case Error at Node j of Layer n Error at Node k of Layer N (Output layer)

  18. Updating Weights : Gradient Descent Method Updating weights and bias

  19. Updating Weights : Gradient Descent with Momentum Method 0< b <1 Momentum term Dw will converge to

  20. Updating Weights : Newton’s Methods From Taylor’s Series where H = Hessian matrix E = Error function (e2) From Taylor’s series, we get or ( Newton’s method )

  21. Updating Weights : Newton’s Methods Advantages: w Fast (quadratic convergence) Disadvantages: wComputationally expensive (requires the computation of inverse matrix operation at each iteration time). w Hessian matrix is difficult to be computed.

  22. Levenberg-Marquardt Backpropagation Methods where J = Jacobian matrix E = All errors I = Identity matrix m = Learning rate

  23. Example : Application of MLP for classification Matlab command : Create training data Input pattern x1 and x2 generated from random numbers x = randn([2 200]); o = (x(1,:).^2+x(2,:).^2)<1; Desired output o: if (x1,x2) lies in a circle of radius 1 centered at the origin then o = 1 else o = 0 x2 x1

  24. Example : Application of MLP for classification (cont.) Matlab command : Create a 2-layer network PR = [min(x(1,:)) max(x(1,:)); min(x(2,:)) max(x(2,:))]; S1 = 10; S2 = 1; TF1 = 'logsig'; TF2 = 'logsig'; BTF = 'traingd'; BLF = 'learngd'; PF = 'mse'; net = newff(PR,[S1 S2],{TF1 TF2},BTF,BLF,PF); Range of inputs No. of nodes in Layers 1 and 2 Activation functions of Layers 1 and 2 Training function Learning function Cost function Command for creating the network

  25. Example : Application of MLP for classification (cont.) Matlab command : Train the network No. of training rounds net.trainParam.epochs = 2000; net.trainParam.goal = 0.002; net = train(net,x,o); y = sim(net,x); netout = y>0.5; Maximum desired error Training command Compute network outputs (continuous) Convert to binary outputs

  26. Example : Application of MLP for classification (cont.) Network structure Output node (Sigmoid) x1 Input nodes x2 Threshold unit (for binary output) Hidden nodes (sigmoid)

  27. Example : Application of MLP for classification (cont.) Initial weights of the hidden layer nodes (10 nodes) displayed as Lines w1x1+w2x2+q = 0

  28. Example : Application of MLP for classification (cont.) Training algorithm: Gradient descent method MSE vs training epochs

  29. Example : Application of MLP for classification (cont.) Results obtained using the Gradient descent method Classification Error : 40/200

  30. Example : Application of MLP for classification (cont.) Training algorithm: Gradient descent with momentum method MSE vs training epochs

  31. Example : Application of MLP for classification (cont.) Results obtained using the Gradient descent with momentum method Classification Error : 40/200

  32. Example : Application of MLP for classification (cont.) Training algorithm: Levenberg-Marquardt Backpropagation MSE vs training epochs (success with in only 10 epochs!)

  33. Example : Application of MLP for classification (cont.) Results obtained using the Levenberg-Marquardt Backpropagation Unused node Only 6 hidden nodes are adequate ! Classification Error : 0/200

  34. Example : Application of MLP for classification (cont.) สรุปการทำงานของ วงจรข่ายนิวรอลในการแยกแยะข้อมูล - ในงานด้าน Classification นิวรอลใน Node ในชั้นต้นๆ จะทำหน้าที่สร้างเส้นแบ่ง พรมแดน (boundary) ของ Class ต่างชนิดกันในเฉพาะช่วงสั้นๆในระดับท้องถิ่น (Local) - ในขณะที่นิวรอลในชั้นสูงๆจะทำหน้าที่รวบรวม เส้นแบ่งพรมแดนแต่ละเส้น จาก Node ล่างๆเข้าประกอบเป็น Global boundary ที่ใช้แบ่งแยกข้อมูลทั้งหมด

  35. Example : Application of MLP for function approximation Function to be approximated x = 0:0.01:4; y = (sin(2*pi*x)+1).*exp(-x.^2);

  36. Example : Application of MLP for function approximation (cont.) Matlab command : Create a 2-layer network PR = [min(x) max(x)] S1 = 6; S2 = 1; TF1 = 'logsig'; TF2 = 'purelin'; BTF = 'trainlm'; BLF = 'learngd'; PF = 'mse'; net = newff(PR,[S1 S2],{TF1 TF2},BTF,BLF,PF); Range of inputs No. of nodes in Layers 1 and 2 Activation functions of Layers 1 and 2 Training function Learning function Cost function Command for creating the network

  37. Example : Application of MLP for function approximation Network structure Output node (Linear) x y Input nodes Hidden nodes (sigmoid)

  38. Example : Application of MLP for function approximation Initial weights of the hidden nodes displayed in terms of the activation function of each node (sigmoid function).

  39. Example : Application of MLP for function approximation Final weights of the hidden nodes after training displayed in terms of the activation function of each node (sigmoid function).

  40. Example : Application of MLP for function approximation Weighted summation of all outputs from the first layer nodes yields function approximation.

  41. Example : Application of MLP for function approximation (cont.) Matlab command : Create a 2-layer network PR = [min(x) max(x)] S1 = 3; S2 = 1; TF1 = 'logsig'; TF2 = 'purelin'; BTF = 'trainlm'; BLF = 'learngd'; PF = 'mse'; net = newff(PR,[S1 S2],{TF1 TF2},BTF,BLF,PF); Range of inputs No. of nodes in Layers 1 and 2 Activation functions of Layers 1 and 2 Training function Learning function Cost function Command for creating the network

  42. Example : Application of MLP for function approximation Network structure No. of hidden nodes is too small ! Function approximated using the network

  43. Example : Application of MLP for function approximation (cont.) Matlab command : Create a 2-layer network PR = [min(x) max(x)] S1 = 5; S2 = 1; TF1 = 'radbas'; TF2 = 'purelin'; BTF = 'trainlm'; BLF = 'learngd'; PF = 'mse'; net = newff(PR,[S1 S2],{TF1 TF2},BTF,BLF,PF); Range of inputs No. of nodes in Layers 1 and 2 Activation functions of Layers 1 and 2 Training function Learning function Cost function Command for creating the network

  44. Example : Application of MLP for function approximation Radiasl Basis Func. Initial weights of the hidden nodes displayed in terms of the activation function of each node (radial basis function).

  45. Example : Application of MLP for function approximation Final weights of the hidden nodes after training displayed in terms of the activation function of each node (Radial Basis function).

  46. Example : Application of MLP for function approximation Function approximated using the network

  47. Example : Application of MLP for function approximation • สรุปการทำงานของ วงจรข่ายนิวรอลในการประมาณค่าฟังก์ชัน - ในงานด้าน Function approximation นิวรอลใน Node ในชั้นต้นๆ จะทำหน้าที่ ประมาณค่าในเฉพาะช่วงสั้นๆในระดับท้องถิ่น (Local) กล่าวคือ นิวรอลใน Node ในชั้นต้นๆ จะตื่นตัว (Active)เฉพาะกับ Input ในช่วงสั้นๆ • ในขณะที่นิวรอลในชั้นสูงๆจะทำหน้าที่รวบรวม output จาก Node ล่างๆเข้า • ประกอบเป็น Globalfunction ที่ครอบคลุม input range ทั้งหมด

More Related