![Page 1: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/1.jpg)
Text Classification
![Page 2: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/2.jpg)
ต้องการตัดประโยคนี้
• Word segmentation : เติมตัวแบ่งคํา
• Input: ร่องระหว่างตัวอักษรในประโยค
• Output: ตัดคําตรงนั้น vs ไม่ตัดคําตรงนั้น
![Page 3: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/3.jpg)
คนงานขนเสื้อขนแกะใส่กระบะ
• Part of speech tagging : แปะชนิดของคํา
• Input: คําแต่ละคํา
• Output: {Noun, Adj, Verb, Adv, Preposition, ..}
![Page 4: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/4.jpg)
โทรศัพท์รุ่นใหม่ๆ แบตเตอรีไม่ค่อยอึดเท่ารุ่นเก่าๆ
• Sentiment Analysis
• Input: ประโยค
• Output: {ทัศนคติแง่บวก, ทัศนคติแง่ลบ, อื่นๆ}
![Page 5: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/5.jpg)
• ให้คะแนนเรียงความอัตโนมัติ
• Input: เรียงความ
• Output: {0, 1, 2, 3, 4, 5}
• ตรวจจับข่าวปลอม
• Input: ข่าว
• Output: {ปลอม, จริง}
![Page 6: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/6.jpg)
3 ปัจจัยหลักๆ ที่ส่งผลต่อคุณภาพของ Text Classifier
1. ปริมาณและคุณภาพของข้อมูล
2. Algorithm e.g. Naive Bayes, Logistic Regression, Random
Forests, Neural networks
3. Feature Engineering
![Page 7: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/7.jpg)
Logistic Regression
![Page 8: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/8.jpg)
ค่าสัญญาณ
f1 (คําว่าต่อต้าน) 1
f2 (คําว่าชื่นชอบ) 0
f3 (จํานวนตัวอักษร) 100
บวก ลบ กลาง
f1 (คําว่าต่อต้าน) -2 2 -1
f2 (คําว่าชื่นชอบ) -1 -0.2 0.4
f3 (จํานวนตัวอักษร) 0.0004 0.005 -0.00001
Parameter ของโมเดล Maximum Entropy หลังจากฝึกเสร็จเรียบร้อยแล้ว
บวก ลบ กลาง
f1 (คําว่าต่อต้าน) 1 x - 2 1 x 2 1 x -1
f2 (คําว่าชื่นชอบ) 0 x -1 0 x -0.2 0 x 0.4
f3 (จํานวนตัวอักษร) 100 * 0.0004 100 x 0.005 100 x -0.00001
![Page 9: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/9.jpg)
บวก ลบ กลาง
f1 (คําว่าต่อต้าน) 1 x - 2 -2 1 x 2 2 1 x -1 -1
f2 (คําว่าชื่นชอบ) 0 x -1 0 0 x -0.2 0 0 x 0.4 0
f3 (จํานวนตัวอัก
ษร)
100 * 0.0004 0.04 100 x 0.005 0.5 100 x -0.00001 -0.001
คะแนนรวม 1.96 2.5 -1.001
บวก ลบ กลาง
f1 -2 2 -1
f2 -1 -0.2 0.4
f3 0.0004 0.005 -0.00001
![Page 10: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/10.jpg)
`(W ;X,Y ) =nX
i=0
logP (Y = yi|xi,W )
=nX
i=0
logexp a(yi;xi,W )Pj exp a(j;x
i,W )
=nX
i=0
log exp a(yi;xi,W )� logX
j
exp a(j;xi,W )
a(j;x,W ) =kX
i=0
wijxi
![Page 11: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/11.jpg)
argmaxW
`(W ;X,Y ) = argminW
�`(W ;X,Y )
Crossentropy lossNegative log-likelihood
Log-likelihood
![Page 12: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/12.jpg)
Stochastic Gradient Descent (SGD)
![Page 13: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/13.jpg)
Optimization Problem
argmaxW
`(W ;X,Y ) = argminW
�`(W ;X,Y )
![Page 14: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/14.jpg)
Gradient-based training/optimization
![Page 15: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/15.jpg)
Gradient of Cross-entropy Loss
argmaxW
`(W ;X,Y ) = argminW
�`(W ;X,Y )
@`(W ;X,Y )
@wij= xi(P (Y = j|X)� (y⇤ = j))
บวก ลบ กลาง
f1 -2 2 -1
f2 -1 -0.2 0.4
f3 0.0004 0.005 -0.00001
ค่าสัญญาณ
f1 1
f2 0
f3 100
![Page 16: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/16.jpg)
Stochastic Gradient Descent
for x, y in training_set: compute P(Y|X) update wij ของใหม่:= wij ของเก่า - α xi (P(Y=j|X) - 1(y=j)
![Page 17: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/17.jpg)
for x, y in training_set: compute P(Y|X) update wij ของใหม่:= wij ของเก่า - α xi (P(Y=j|X) - 1(y=j)
for x, y in training_set: compute P(Y|X) gradientij += xi (P(Y=j|X) - 1(y=j)update wij ของใหม่:= wij ของเก่า - α gradientij
Stochastic Gradient Descent
Batch Gradient Descent
![Page 18: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/18.jpg)
Gradient-based training/optimization
![Page 19: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/19.jpg)
Feedforward Neural Network
![Page 20: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/20.jpg)
f1 f2 f3
บวก -2 -1 0
ลบ 2 0 0
กลาง -1 0.4 0
f1 1
f2 0
f3 100
![Page 21: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/21.jpg)
f1 f2 f3
บวก -2 -1 0
ลบ 2 0 0
กลาง -1 0.4 0
0.001
0.006
0.002
1.961
2.506
-0.999
+f1 1
f2 0
f3 100
o = softmax(WTx+ b)
=
![Page 22: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/22.jpg)
f1 f2 f3
บวก -2 -1 0
ลบ 2 0 0
กลาง -1 0.4 0
f1 1
f2 0
f3 100
![Page 23: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/23.jpg)
f1 1
f2 0
f3 100
![Page 24: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/24.jpg)
Rectified Linear Unit (ReLU) Hyperbolic Tangent (tanh)
![Page 25: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/25.jpg)
Backpropagation
![Page 26: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/26.jpg)
Training Neural Network
![Page 27: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/27.jpg)
Techniques in Neural Network Training
• Automatic gradient computation
• Dropout
• Learning Rate
![Page 28: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/28.jpg)
Distributional Semantics
![Page 29: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/29.jpg)
Techniques in Neural Network Training
• Automatic gradient computation
• Dropout
• Learning Rate
![Page 30: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/30.jpg)
Word Embedding
![Page 31: neural network part 1 - GitHub Pages · ค่าสัญญาณ f1 (คําว่าต่อต้าน) 1 f2 (คําว่าชื่นชอบ) 0 f3 (จํานวนตัวอักษร)](https://reader034.vdocuments.mx/reader034/viewer/2022042200/5e9f3f5f6fb550227a4ed9bf/html5/thumbnails/31.jpg)
Techniques in Neural Network Training
• Automatic gradient computation
• Dropout
• Learning Rate