SlideShare ist ein Scribd-Unternehmen logo
1 von 95
หัวใจของปัญญาประดิษฐ์(A.I.)
และความน่าตื่นเต้นของ Deep Learning
ดร. กอบกฤตย์ วิริยะยุทธกร
kobkrit@iapp.co.th
บริษัท ไอแอพพ์เทคโนโลยี จำกัด
http://ai.iapp.co.th
นิยามของปัญญาประดิษฐ์
“ทาให้เครื่องที่สามารถปฏิบัติงานที่เป็ นลักษณะของปัญญาของมนุษย์”
วำงแผน
เข้ำใจภำษำ
รู้จำวัตถุ
รู้จำเสียง
สำมำรถเรียนรู้ได้ด้วยตัวเอง
แก้ปัญหำได้
A.I.
2
General AI & Narrow AI
• General AI ปัญญาประดิษฐ์ทั่วไป
• Narrow AI ปัญญาประดิษฐ์แบบแคบ
วำงแผน
เข้ำใจภำษำ รู้จำวัตถุ
รู้จำเสียง
สำมำรถเรียนรู้ได้ด้วยตัวเอง
แก้ปัญหำได้
A.I.
3
อะไรคือปัญญาประดิษฐ์
ปัญญำประดิษฐ์
ภาพ
ข้อมูลนาเข้า ข้อมูลนาออก
“แมว”
AI
4
ปัญญาประดิษฐ์ต่างจากโปรแกรมคอมพิวเตอร ์
อย่างไร
5
โมเดลปัญญำประดิษฐ์
ภาพ
ข้อมูลนาเข้า ข้อมูลนาออก
“แมว”
โปรแกรมคอมพิวเตอร์
(จริงๆ จะมองเป็น AI ก็ได้)
น้าหนัก = 70 กก. ความสูง = 170 cm BMI = 24.2
เขียนโปรแกรม
ยังไงดี!????
AI
ปัญญาประดิษฐ์สร้างได้อย่างไร
• เขียนโปรแกรมด้วยมนุษย์(Manual Program)
• อย่ำงเช่นเขียนโปรแกรมให้ค้นหำคำตอบที่ดีสุดจำกคำตอบทั้งหมด โดยใช้ประโยชน์จำกควำมเร็วของเครื่อง
• คนเขียนบอกวิธีให้หมด ไม่จำเป็นต้องใช้ข้อมูลในกำรเรียนรู้
AI
6
ปัญญาประดิษฐ์สร้างได้อย่างไร
• ใช้เทคนิคการเรียนรู ้ด้วยเครื่อง (Machine Learning)
• คนไม่ต้องเขียนโปรแกรมบอกทุกขั้นตอน ให้คอมพิวเตอร์สำมำรถเรียนรู้จำกข้อมูลได้ด้วยตัวเอง
• ต้องใช้ข้อมูลมหำศำล
AI
7
การเรียนรู ้ด้วยเครื่อง (Machine Learning)
• คือหนทำงที่ทำให้คอมพิวเตอร์ฉลำดจำกกำรที่สำมำรถเรียนรู้ได้ด้วยตัวเอง
• เป็นหนทำงหลักของกำรสร้ำงปัญญำประดิษฐ์ในปัจจุบัน
• โจทย์ A.I. นั้นยำกและซับซ้อนเกินว่ำที่มนุษย์จะเขียนโปรแกรมออกมำได้
• ต้องใช้ข้อมูล (Data) จำนวนมำก (Big Data) เพื่อให้คอมพิวเตอร์สำมำรถหำควำมสัมพันธ์ระหว่ำงข้อมูลนำเข้ำ (Input)
และคำตอบ (Output) ได้อัตโนมัติ
ML
8
การเรียนรู ้ด้วยเครื่อง (Machine Learning)
ML
9
ML
10
การเรียนรู ้แบ่งได้ 3 ประเภท
ML
11
Supervised Learning (มีเฉลย)
ML
12
Classification (คัดแยกประเภท)
สี: เขียว
เส้นผ่านศูนย์กลาง: 25 cm
เฉลย: ??
ML
13
Regression (ทานายอนาคต)
0
3.5
7
10.5
14
0 1.5 3 4.5 6 7.5x=6
เฉลย: ??
ML
14
Unsupervised Learning (ไม่มีเฉลย)
ML
15
Clustering
มีกี่กลุ่ม?
กลุ่มแต่ละกลุ่มอยู่ที่ไหนบ้าง?
ML
16
Anomaly Detection
Kobkrit Viriyayudhakorn
Location: BKK
Age: 32
Job Role: Data Scientist
Time/Date Shop Location Channel Amount
25 Nov 13:29 Fuji Restaurant Bangkok POS THB350.78
25 Nov 14:01 Asia Book Bangkok POS THB150
25 Nov 14:02 Dermstore Saint Petersburg POS
60000 Russian
ruble ->
29,905.02 THB
25 Nov 19.07 Google Ads Singapore Internet
215 SGD ->
5,171.67 THB
อันไหนเป็ น
Fraud?
Credit Card Statement
ML
17
Reinforcement Learning
ML
18
Autonomous Car
Actions:
Reward:
จานวน KM ที่เข้าใกล้เชียงใหม่มากขึ้น +1
จานวนเวลาที่ใช้ต่อนาที -0.001
ทาผิดกฏจราจร -100
เกิดอุบัติเหตุ -999999
กรุงเทพ เชียงใหม่
700km
Environment:
Observation:
ML
19
การเรียนรู ้ด้วยเครื่อง (Machine Learning)
ML
20
วิธีการสร้าง Label Dataset เพื่อ Machine Learning
มนุษย์ใช้ไม้บรรทัดวัด
Features = X Output = Y
ML
Feature Engineering
Structure Data
21
Machine Learning ทางานอย่างไร
x (Input) y (Output)
0 1
1 3
2 5
3 7
????x y
หัวใจของปัญญาประดิษฐ์Gradient Descent
22
Machine Learning ทางานอย่างไร
x (Input) y (Output)
0 1
1 3
2 5
3 7
y=2x+1x y
หัวใจของปัญญาประดิษฐ์Gradient Descent
23
Machine Learning ทางานอย่างไร
x (Input) y (Output)
0 1
1 3
2 5
3 7
y=ax+bx y
ใบ้คอมพิวเตอร ์ให้ว่าเป็ นสมการเส้นตรง*นะ
* เพื่อความง่ายต่อการเข้าใจ จริงๆแล้วมี ML สามารถรับรองสมการได้ทุกรูปแบบ
หัวใจของปัญญาประดิษฐ์Gradient Descent
24
การคาดเดา h (Prediction)
ค่ำ h คือคำตอบที่เกิดจำก กำรเดำจำก a และ b คำนวณโดย h = ax +b
กาหนดให้ค่า
ค่ำ y คือคำตอบที่ถูกต้อง
x (Input) y (Output)
0 1
1 3
2 5
3 7
• สมมุติ A.I. เดำค่ำมำว่ำค่ำ a = 1 ค่ำ b = 0.5
• ในแถวแรกค่ำ x = 0, y = 1
• ค่ำ h = ax + b = 1*0 + 0.5 = 0.5
• เมื่อเทียบกับ y = 1 A.I. ยังเดำค่ำผิดไป 0.5
** สนใจเฉพำะแถวแรกก่อน **
หัวใจของปัญญาประดิษฐ์Gradient Descent
25
• วิธีกำรคำนวณควำมแตกต่ำงระหว่ำงค่ำจริง (y) กับค่ำที่เรำเดำ (h) ในแต่ละแถวข้อมูล เรียกว่ำ Lost Function
• ค่ำ Lost ยิ่งเยอะยิ่งเดำผิด ถ้ำ Lost = 0 ก็จะเดำถูกหมดเลย
• Lost Function ที่ง่ำยที่สุดในแวบแรกคือ = 𝒚 − 𝒉
• แต่ใช้ไม่ได้จริง เพรำะถ้ำ y ติดลบ จะไม่สำมำรถใช้ได้
• ดังนั้น Lost Function ที่ง่ำยที่สุดๆ (จริง) คือ
• แต่เพื่อควำมง่ำยในกำรคำนวณ Derivative จึงใส่ 1/2 ไปข้ำงหน้ำด้วย
Lost Function
หัวใจของปัญญาประดิษฐ์Gradient Descent
26
(𝒚 − 𝒉) 𝟐
𝟏
𝟐
(𝒚 − 𝒉) 𝟐
Cost Function
x (Input) y (Output) h (Predict) Lost Value
0 1 0.5 0.125
1 3 1.5 1.125
2 5 2.5 3.125
3 7 3.5 6.125
Cost (Sum) 10.5
• h = ax +b โดยที่เรำเดำสุ่มมำว่ำ a = 1 และ b = 0.5, h = 1x + 0.5
• Lost Function =
• Cost คือผลรวมของ Error ทั้งหมดของ Data ในที่ใช้ในกำร Train = 10.5
• Cost function (Sum of Square Error, SSE) = = 10.5
หัวใจของปัญญาประดิษฐ์Gradient Descent
27
𝒊=𝟏
𝒏
𝟏
𝟐
(𝒚𝒊 − 𝒉𝒊) 𝟐
สรุปการเดารอบแรก
• หำกเรำเดำ a = 1 และ b = 0.5 ในรอบแรก
• เรำจะผลรวมค่ำผิดพลำด (Cost Value) = 21
• เรำต้องกำรที่จะให้ผลรวมค่ำผิดพลำดลดลงให้มำกที่สุด (Cost Value) = 0 เพื่อให้โมเดลทำงำนได้อย่ำงถูกต้อง เรำ
จะต้องทำอย่ำงไร??
• เรำก็ต้องปรับค่ำกำรเดำ a และ b ใหม่สิ ให้มันถูกต้องมำกยิ่งขึ้น
หัวใจของปัญญาประดิษฐ์Gradient Descent
28
วิธีการเดาแบบเป็ นระบบ
• แน่นอนวิธีกำรเดำเป็นระบบก็ต้องลองลดหรือเพิ่มตัวแปรทีละตัว
• ลองเปลี่ยนแปลงค่ำ a ดูก่อน แต่เดิม a = 1
• หำกเรำลด a ไป 0.1 => 1.0 - 0.1 = 0.9
• หำกเรำเพิ่ม a ไป 0.1 => 1.0 + 0.1 = 1.1
- - a ++
10 2
หัวใจของปัญญาประดิษฐ์Gradient Descent
29
x (Input) y (Output) h (Predict) Lost Value
0 1 0.5 0.125
1 3 1.4 1.28
2 5 2.3 3.645
3 7 3.2 7.22
Cost (Sum) 12.27
• h = ax +b โดยที่ a = 0.9 และ b = 0.5
ลองลด a ลง 0.1 (จากเดิม 1)
หัวใจของปัญญาประดิษฐ์Gradient Descent
30
x (Input) y (Output) h (Predict) Error Value
0 1 0.5 0.125
1 3 1.6 0.98
2 5 2.7 2.645
3 7 3.8 5.12
Cost (Sum) 8.87
• h = ax +b โดยที่ a = 1.1 และ b = 0.5
ลองเพิ่ม a ขึ้น 0.1 (จากเดิม 1)
หัวใจของปัญญาประดิษฐ์Gradient Descent
31
x (Input) y (Output) h (Predict) Error Value
0 1 0.4 0.18
1 3 1.4 1.28
2 5 2.4 3.38
3 7 3.4 6.48
Cost (Sum) 11.32
• h = ax +b โดยที่ a = 1 และ b = 0.4
ลองลด b ลง 0.1 (จากเดิม 0.5)
หัวใจของปัญญาประดิษฐ์Gradient Descent
32
x (Input) y (Output) h (Predict) Error Value
0 1 0.6 0.08
1 3 1.6 0.98
2 5 2.6 2.88
3 7 3.6 5.78
Cost (Sum) 9.72
• h = ax +b โดยที่ a = 1 และ b = 0.6
ลองเพิ่ม b ขึ้น 0.1 (จากเดิม 0.5)
หัวใจของปัญญาประดิษฐ์Gradient Descent
33
ค่า Cost Value เปลี่ยนแปลงไปตามค่าของ a,b
10.5
10.9 1.1
12.27 8.87
Total Error
ค่าของ a
10.5
0.50.4 0.6
11.32 9.72
Total Error
ค่าของ b
2
1
หัวใจของปัญญาประดิษฐ์Gradient Descent
34
การเดาแบบมีระบบ
• กำรเดำแบบมีระบบพอบอกเรำได้ว่ำต้องปรับ a, b ไปยังทิศทำงใดเพื่อให้ Cost Value ได้ต่ำที่สุด
• แต่โจทย์ของเรำง่ำยมำก มีแค่ 2 ตัวแปร หำกใช้เวลำไม่นำนก็น่ำจะหำคำตอบได้ เนื่องจำกเฉลยของเรำยังเป็นเบอร์ที่ลงตัวง่ำย
อีกด้วย (a = 2, b =1)
• แต่โจทย์ AI จริงๆนั้น มีตัวแปรแบบ a,b ถึง 100 ล้ำนตัวแปร แล้วตัวเลขที่ดีที่สุดของแต่ละตัวแปรที่ต้องคำดเดำไปเรื่อยๆ โดย
ที่ไม่รู้ว่ำต้องปรับค่ำในปริมำณสัดส่วนเท่ำไร
• นอกจำกนี้ตัวแปรแต่ละตัวก็ล้วนมีควำมสัมพันธ์กันทำให้กำรเปลี่ยนค่ำตัวนึง ภำยใต้ค่ำตัวแปรอีกตัวนึงก็มีผลที่แตกต่ำงกัน
ส่งผลต่อค่ำ Cost Value ที่แตกต่ำงกันอีกด้วย
หัวใจของปัญญาประดิษฐ์Gradient Descent
35
การเดาแบบมีระบบ ดี แต่ยังใช้ไม่ได้ในโจทย์จริง
768 px
1024 px
• จำกรูปแมว 1 รูปมีขนำด 1024 x 768 = 786,432
Pixel
• แล้วแต่ละ Pixel มีค่ำสีได้ถึง 16 ล้ำนสี
• กำรจะหำตัวแปรเพื่อให้ Cost Function Value ที่ใช้ใน
กำรแยกแยะแมวหรือสุนัขต่ำที่สุด อำจจะต้องใช้กำรคำนวณ
มำกถึง
• ln2(786,43216,000,000) คำสั่ง
• ใช้เวลำชั่วนิรันด์ในกำรคำนวณด้วยคอมพิวเตอร์ในยุคปัจจุบัน
หัวใจของปัญญาประดิษฐ์Gradient Descent
36
ขั้นตอนการเรียนรู ้ด้วย Gradient Descent
• เรำมีวิธีที่ดีกว่ำกำรเดำไปเรื่อยๆ ต้องขอบคุณที่เรำมี Calculus
Cost function
A
B
• Gradient Descent ทำให้เรำสำมำรถ
รู้ว่ำเรำต้องปรับค่ำไปทำงไหนแต่ละตัวแปรในสัดส่วนเท่ำไร แล้วทำ
ให้ค่ำ Cost function วิ่งเข้ำหำจุดที่ต่ำที่สุดตำม Slope ที่ชัน
ที่สุด
• ใช้เทคนิคคล้ำยๆกับกำรเดำแบบมีระบบแต่เรำสำมำรถค่ำสัดส่วนที่
เหมำะสม (วิ่งหำ Slope ที่ชันที่สุด) ได้ทันที
Leibniz Newton
หัวใจของปัญญาประดิษฐ์Gradient Descent
37
• Calculus คือกำรหำควำมชัน
• สมุมติว่ำเรำพิจำรณำ A ก่อน
หา d(y)/d(x) =
ถ้า x = 1, ความชัน = 2(1-2) = -2
ถ้า x = 3 ความชัน = 2(3-2) = 2
x=1 x=3
Cost function
A
B
หัวใจของปัญญาประดิษฐ์Gradient Descent
38
• Cost function (Sum of Square Error) =
• กำรปรับค่ำ a และ b ที่ดีที่สุดก็คือหำค่ำ Slope ของ a และ b
บน Cost Function
• Slope ของ a =
วิธีการหาค่าที่เหมาะสมสาหรับการปรับค่า a, b
Cost function
A
B
𝜕(𝑆𝑆𝐸)
𝜕(𝑎)
=
𝜕 𝑆𝑆𝐸
𝜕(ℎ)
𝜕(ℎ)
𝜕(𝑎)
𝒊=𝟏
𝒏
𝟏/𝟐 𝒚𝒊 − 𝒉𝒊 2
𝜕 𝑆𝑆𝐸
𝜕(ℎ)
=
𝜕( 𝑖=1
𝑛
1/2 𝑦𝑖
−ℎ𝑖 2)
𝜕 (ℎ)
= - 𝑦𝑖 − ℎ𝑖
𝜕(ℎ)
𝜕(𝑎)
=
𝜕( 𝑎𝑥+𝑏)
𝜕 (𝑎)
= x
𝝏(𝑺𝑺𝑬)
𝝏(𝒂)
= - 𝒚𝒊 − 𝒉𝒊 𝐱
Slope ของ b =
𝜕(𝑆𝑆𝐸)
𝜕(𝑏)
=
𝜕 𝑆𝑆𝐸
𝜕(ℎ)
𝜕(ℎ)
𝜕(𝑏)
𝜕(ℎ)
𝜕(𝑏)
=
𝜕( 𝑎𝑥+𝑏)
𝜕 (𝑏)
= 1
𝝏(𝑺𝑺𝑬)
𝝏(𝒃)
= - 𝒚𝒊 − 𝒉𝒊
หัวใจของปัญญาประดิษฐ์Gradient Descent
39
วิธีการหา Cost ที่ต่าที่สุดด้วย Gradient Descent
1. มั่วค่ำ a,b ขึ้นมำค่ำนึง
2. คำนวณค่ำ Cost function (Sum of Square Error)
3. คำนวณหำ Slope ของ a =
𝝏(𝑺𝑺𝑬)
𝝏(𝒂)
, b =
𝝏(𝑺𝑺𝑬)
𝝏(𝒃)
ที่ชันที่สุด
4. เปลี่ยนค่ำ a = a − 𝛼
𝝏(𝑺𝑺𝑬)
𝝏(𝒂)
และ b = b − 𝛼
𝝏(𝑺𝑺𝑬)
𝝏(𝒃)
5. ทำ 2-4 ไปเรื่อยจนค่ำ Cost function เข้ำใกล้ 0 หรือในจุดที่เรำพอใจ
𝛼 = Learning Rate
มักจะเป็ นค่าน้อย
มากๆ (0.001) เพื่อ
ไม่ให้มันลง Slope เร็ว
เกินไป (เดี๋ยวเลย)
หัวใจของปัญญาประดิษฐ์Gradient Descent
40
หัวใจของปัญญาประดิษฐ์Gradient Descent
41
Gradient Descent Step-by-Step #1
• h = ax +b โดยที่ a = 1.0 และ b = 0.5
𝝏(𝑺𝑺𝑬)
𝝏(𝒂)
= - 𝒚𝒊 − 𝒉𝒊 𝐱 = -17
𝝏(𝑺𝑺𝑬)
𝝏(𝒃)
= - 𝒚𝒊 − 𝒉𝒊 = -8
𝛼 = 0.01
x (Input) y (Output) h (Predict) Error -(y-h) -(y-h)x
0 1 0.5 0.125 -0.5 0
1 3 1.5 1.125 -1.5 -1.5
2 5 2.5 3.125 -2.5 -5
3 7 3.5 6.125 -3.5 -10.5
Sum 10.5 -8 -17
a = a − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒂
= 𝟏 − 𝟎. 𝟎𝟏 −𝟏𝟕 = 𝟏. 𝟏𝟕
b = b − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒃
= 𝟎. 𝟓 − 𝟎. 𝟎𝟏 −𝟖 = 𝟎. 𝟓𝟖
หัวใจของปัญญาประดิษฐ์Gradient Descent
42
Gradient Descent Step-by-Step #2
• h = ax +b โดยที่ a = 1.17 และ b = 0.58
𝝏(𝑺𝑺𝑬)
𝝏(𝒂)
= - 𝒚𝒊 − 𝒉𝒊 𝐱 = -14.14
𝝏(𝑺𝑺𝑬)
𝝏(𝒃)
= - 𝒚𝒊 − 𝒉𝒊 = -6.66
𝛼 = 0.01
x (Input) y (Output) h (Predict) Lost Value -(y-h) -(y-h)x
0 1 0.58 0.0882 -0.42 0
1 3 1.75 0.78125 -1.25 -1.25
2 5 2.92 2.1632 -2.08 -4.16
3 7 4.09 4.23405 -2.91 -8.73
Sum 7.2667 -6.66 -14.14
a = a − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒂
= 𝟏. 𝟏𝟕 − 𝟎. 𝟎𝟏 −𝟏𝟒. 𝟏𝟒 = 𝟏. 𝟑𝟏
b = b − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒃
= 𝟎. 𝟓𝟖 − 𝟎. 𝟎𝟏 −𝟔. 𝟔𝟔 = 𝟎. 𝟔𝟓
หัวใจของปัญญาประดิษฐ์Gradient Descent
43
Gradient Descent Step-by-Step #3
• h = ax +b โดยที่ a = 1.31 และ b = 0.65
𝝏(𝑺𝑺𝑬)
𝝏(𝒂)
= - 𝒚𝒊 − 𝒉𝒊 𝐱 = -11.76
𝝏(𝑺𝑺𝑬)
𝝏(𝒃)
= - 𝒚𝒊 − 𝒉𝒊 = -5.54
𝛼 = 0.01
x (Input) y (Output) h (Predict) Lost Value -(y-h) -(y-h)x
0 1 0.65 0.06125 -0.35 0
1 3 1.96 0.5408 -1.04 -1.04
2 5 3.27 1.49645 -1.73 -3.46
3 7 4.58 2.9282 -2.42 -7.26
Sum 5.0267 -5.54 -11.76
a = a − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒂
= 𝟏. 𝟒𝟐
b = b − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒃
= 𝟎. 𝟕𝟎
หัวใจของปัญญาประดิษฐ์Gradient Descent
44
Gradient Descent Step-by-Step #4
• h = ax +b โดยที่ a = 1.42 และ b = 0.70
𝝏(𝑺𝑺𝑬)
𝝏(𝒂)
= - 𝒚𝒊 − 𝒉𝒊 𝐱 = -9.92
𝝏(𝑺𝑺𝑬)
𝝏(𝒃)
= - 𝒚𝒊 − 𝒉𝒊 = -4.68
𝛼 = 0.01
x (Input) y (Output) h (Predict) Lost Value -(y-h) -(y-h)x
0 1 0.7 0.045 -0.3 0
1 3 2.12 0.3872 -0.88 -0.88
2 5 3.54 1.0658 -1.46 -2.92
3 7 4.96 2.0808 -2.04 -6.12
Sum 3.5788 -4.68 -9.92
a = a − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒂
= 𝟏. 𝟓𝟏
b = b − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒃
= 𝟎. 𝟕𝟒
หัวใจของปัญญาประดิษฐ์Gradient Descent
45
ทาไปเรื่อยๆถึงรอบที่ 25
1 รอบ = 1 epoch
หัวใจของปัญญาประดิษฐ์Gradient Descent
46
Gradient Descent Step-by-Step #25
• h = ax +b โดยที่ a = 2.004 และ b = 0.973
𝝏(𝑺𝑺𝑬)
𝝏(𝒂)
= - 𝒚𝒊 − 𝒉𝒊 𝐱 = -0.09
𝝏(𝑺𝑺𝑬)
𝝏(𝒃)
= - 𝒚𝒊 − 𝒉𝒊 = -0.07
𝛼 = 0.01
x (Input) y (Output) h (Predict) Lost Value -(y-h) -(y-h)x
0 1 0.973631 0.000348 -0.02637 0
1 3 2.978477 0.000232 -0.02152 -0.021523
2 5 4.983323 0.000139 -0.01668 -0.033354
3 7 6.988169 7E-05 -0.01183 -0.035492
Sum 0.000788 -0.0764 -0.090369
a = a − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒂
= 𝟐. 𝟎𝟎𝟓
b = b − 𝛼
𝝏 𝑺𝑺𝑬
𝝏 𝒃
= 𝟎. 𝟗𝟕𝟒
หัวใจของปัญญาประดิษฐ์Gradient Descent
47
ในที่สุด A.I. ก็ค้นพบคาตอบ
x (Input) y (Output)
0 1
1 3
2 5
3 7
y=2.005x+0.974x y
หัวใจของปัญญาประดิษฐ์Gradient Descent
y=2x+1x y
48
แต่ยัง ยังไม่จบ This is just the beginning
นี่แหละคือ Gradient Descent นี่คือหัวใจของ A.I. ทั้งมวล
A.I.และ Machine Learning ทุกตัวสร้ำง
จำกพื้นฐำนของ Gradient Descent ทั้งหมด
ยินดีด้วย หำกท่ำนเข้ำใจ Gradient Descent ถือว่ำท่ำนเข้ำใจหัวใจของ A.I. แล้ว
49
หัวใจของปัญญาประดิษฐ์ Gradient Descent
เทคนิคทาง Machine Learning
• Linear Regression คือสิ่งที่พึ่งได้เรียนไป
50
Supervised Learning ML
เทคนิคทาง Machine Learning
• Logistic Regression คือเทคนิคกำรแบ่งแยกข้อมูลเป็น 2 Class
51
Supervised Learning ML
เทคนิคทาง Machine Learning
• Linear Discriminant Analysis คือเทคนิคกำรแบ่งแยกข้อมูลมำกกว่ำ 2 Class
52
Supervised Learning ML
เทคนิคทาง Machine Learning
• Classification and Regression Trees กำรแบ่งแยกแบบตัดสินใจเป็นชั้นๆ
53
Supervised Learning ML
เทคนิคทาง Machine Learning
• Naive Bayes: กำรแบ่งแยกแบบตัดสินใจตำมหลักควำมเป็นไปได้แบบมีเงื่อนไข (Conditional Probability)
54
Supervised Learning ML
เทคนิคทาง Machine Learning
• Support Vector Machine คือเทคนิคกำรแบ่งแยกข้อมูลมำกกว่ำ 2 Class ที่สนใจในกำรวำดเส้นตัดสินใจระหว่ำง 2 Class ให้
กว้ำงที่สุดเท่ำที่ทำได้ และมีเทคนิคกำรแปลง Space ข้อมูล (Kernel Method) เป็นเทคนิค ML ที่แม่นยำและยอดนิยมที่สุด ก่อน
ยุค Deep Learning
55
Supervised Learning ML
เทคนิคทาง Machine Learning
• Neural Network: สำมำรถจับควำมสัมพันธ์และแบ่งแยกได้อย่ำงยอดเยี่ยม และเป็นพื้นฐำนสำคัญของ AI ยุคใหม่ (Deep
Learning)
56
Supervised Learning ML
เทคนิคทาง Machine Learning
• K-nearest Neighbors: จับกลุ่มข้อมูลด้วยดูจำกควำมใกล้ของ Features
57
Unsupervised Learning ML
เทคนิคทาง Machine Learning
• Random Forest: คือเทคนิคกำรให้ ML หลำยๆตัว รับข้อมูลไม่เท่ำกันและช่วยกัน Vote ในกำรตัดสินใจ ถือว่ำเป็น
เทคนิคกำรรวมกลุ่มกันช่วยแบบนึง (Ensemble Learning) ทำให้ควำมแม่นยำสูงขึ้นกว่ำ Train Model เดี่ยวๆ
58
Unsupervised Learning ML
เทคนิคทาง Machine Learning
• Adaboost: คือเทคนิคกำรให้ ML หลำยๆตัว โดยให้ตัวใหม่แก้ไขข้อผิดพลำดของตัวเก่ำไปเรื่อยๆ ถือว่ำเป็นเทคนิคกำร
รวมกลุ่มกันช่วยแบบนึง (Ensemble Learning) ทำให้ควำมแม่นยำสูงขึ้นกว่ำ Train Model เดี่ยวๆ
59
Unsupervised Learning ML
Deep Learning
กำรเรียนรู้เชิงลึก
อะไรคือ Deep Learning
61
DL
อะไรคือ Deep Learning
62
DL
ความสามารถของ Deep Learning
63
DL
ความสามารถของ Deep Learning
64
DL
ความสามารถของ Deep Learning
65
DL
ประวัติ Deep Learning
DL
66
ทาไม Deep Learning ถึงสาเร็จ
67
DL
การเก็บข้อมูลสาหรับ Deep Learning
68
การเก็บข้อมูลสาหรับ Deep Learning
• เพื่อที่จะได้ข้อมูลที่ครบถ้วนที่สุด Deep Learning ที่ไม่ต้องให้มนุษย์มำทำกำร Feature Engineer ให้อีกต่อไป ตัว
Deep Learning จะเป็นคนคัดเลือก Feature ให้เอง
• Machine Learning : ทำ Classifer ประเภทดอกไม้ คนที่คิดว่ำอะไรเป็นตัวที่แสดงควำมแตกต่ำงของแต่ละ
ประเภทดอกไม้แล้ว ไปวัดด้วยไม้บรรทัดแล้วแล้ว กรอกเป็นข้อมูลเข้ำไป
• Deep Learning: ถ่ำยรูปดอกไม้ส่งเข้ำไป Classifer เลย
• มีควำมแม่นยำสูงกว่ำ Machine Learning อย่ำงเห็นได้ชัด
• ต้องกำรข้อมูลและพลังกำรคำนวณมำกขึ้น
69
DL
วิธีการสร้าง Label Dataset เพื่อ Machine Learning
มนุษย์ใช้ไม้บรรทัดวัด
Features = X Output = Y
Feature Engineering
Structure Data
70
DL
วิธีการสร้าง Label Dataset เพื่อ Deep Learning
Unstructured Data
71
DL
Deep Learning ทางานอย่างไร
72
DL
73
DL
Neural Network: Root of Deep Learning
74
DL
Neural Network: Human Brain Cell
75
DL
Neural Network: Activation Function
76
DL
Convolutional Neural Nets (CNN)
77
DL
78
DL
79
80
Fast R-CNN
Faster R-CNN
81
YOLO
Recurrent Neural Network (RNN)
82
DL
83
DL
RNN สามารถแต่งบทความได้
84
DL
Image Captioning: CNN + RNN
85
DL
Natural Language Processing
86
DL
Word Embedding Arithmetic
87
DL
Thai Word Embedding
88
DL
Deep Q-Learning
89
DL
Deep Q-Learning
90
DL
91
DL
สรุป ปัญญาประดิษฐ์/Machine Learning/Deep Learning
92
สรุป
• ปัญญำประดิษฐ์เรียนรู้โลกผ่ำนข้อมูลที่ข้อมูลมนุษย์ใส่เข้ำไป
• ปัญญำประดิษฐ์ จริงๆแล้ว มันไม่ใช่ Magic อะไร เป็นเพียงแค่หลักการคานวณทางคณิตศาสตร ์เพื่อสามารถลดความ
ผิดพลาดไปเรื่อยๆเท่านั้น (Gradient Descent) ซึ่งเป็ นหัวใจของ AI
• ปัญญำประดิษฐ์ยังไม่เข้ำใจหรอกว่ำตัวเองกำลังทำอะไรอยู่และไม่รู้ตัวด้วย (ยังไม่มีสติ) เหมือนกับกล้ำมเนื้อหัวใจที่เต้นเพรำะมีกระแสไฟฟ้ำสั่ง ยังไม่สำมำรถ
ควบคุมตัวเองได้ จังหวะที่ปัญญำประดิษฐ์จะมีสติแล้วสำมำรถพัฒนำตัวเองได้เองเรียกว่ำ Singularity
• ปัญญำประดิษฐ์ยังขำดด้ำนความคิดสร้างสรรค์และยังขำดความเข้าใจมนุษย์
• ปัญญำประดิษฐ์กำลังเติบโตจำกโลกงำนวิจัย มำยังโลกธุรกิจที่จับต้องได้ และเข้ำถึงทุกคนมำกขึ้นเรื่อยๆ มันจะพัฒนำให้ ดีขึ้น เร็วขึ้น และลดต้นทุน
ได้มหาศาล
• ปัญญำประดิษฐ์จะเปลี่ยนแปลงกำรทำงำนของมนุษย์ โดยที่งานที่ทาซ้าๆ จะถูกทดแทนด้วย A.I. มากขึ้นเรื่อยๆ
93
Q/A
• ลองเล่น AI ฝีมือคนไทย
• http://ai.iapp.co.th
94
Reference
• https://www.slideshare.net/LuMa921/deep-learning-a-visual-introduction
• https://www.slideshare.net/mahutte/introduction-to-statistical-machine-learning-14028152
• https://www.deeplearningbook.org/
• https://github.com/cstorm125/thai2vec
• http://web.stanford.edu/class/cs20si/syllabus.html
• https://www.wolframalpha.com
• https://www.kdnuggets.com/2017/04/simple-understand-gradient-descent-algorithm.html
• https://towardsdatascience.com/a-tour-of-the-top-10-algorithms-for-machine-learning-newbies-dde4edffae11
95

Weitere ähnliche Inhalte

Was ist angesagt?

MIRU2020長尾賞受賞論文解説:Attention Branch Networkの展開
MIRU2020長尾賞受賞論文解説:Attention Branch Networkの展開MIRU2020長尾賞受賞論文解説:Attention Branch Networkの展開
MIRU2020長尾賞受賞論文解説:Attention Branch Networkの展開Hironobu Fujiyoshi
 
(文献紹介)深層学習による動被写体ロバストなカメラの動き推定
(文献紹介)深層学習による動被写体ロバストなカメラの動き推定(文献紹介)深層学習による動被写体ロバストなカメラの動き推定
(文献紹介)深層学習による動被写体ロバストなカメラの動き推定Morpho, Inc.
 
パターン認識と機械学習6章(カーネル法)
パターン認識と機械学習6章(カーネル法)パターン認識と機械学習6章(カーネル法)
パターン認識と機械学習6章(カーネル法)Yukara Ikemiya
 
形状解析のための楕円フーリエ変換
形状解析のための楕円フーリエ変換形状解析のための楕円フーリエ変換
形状解析のための楕円フーリエ変換Tsukasa Fukunaga
 
「3.1.2最小二乗法の幾何学」PRML勉強会4 @筑波大学 #prml学ぼう
「3.1.2最小二乗法の幾何学」PRML勉強会4 @筑波大学 #prml学ぼう 「3.1.2最小二乗法の幾何学」PRML勉強会4 @筑波大学 #prml学ぼう
「3.1.2最小二乗法の幾何学」PRML勉強会4 @筑波大学 #prml学ぼう Junpei Tsuji
 
지적 대화를 위한 깊고 넓은 딥러닝 PyCon APAC 2016
지적 대화를 위한 깊고 넓은 딥러닝 PyCon APAC 2016지적 대화를 위한 깊고 넓은 딥러닝 PyCon APAC 2016
지적 대화를 위한 깊고 넓은 딥러닝 PyCon APAC 2016Taehoon Kim
 
モバイル向けEdgeTPUの紹介
モバイル向けEdgeTPUの紹介モバイル向けEdgeTPUの紹介
モバイル向けEdgeTPUの紹介卓然 郭
 
深層ニューラルネットワークの積分表現(Deepを定式化する数学)
深層ニューラルネットワークの積分表現(Deepを定式化する数学)深層ニューラルネットワークの積分表現(Deepを定式化する数学)
深層ニューラルネットワークの積分表現(Deepを定式化する数学)Katsuya Ito
 
コンピュータ将棋・囲碁における機械学習活用
コンピュータ将棋・囲碁における機械学習活用コンピュータ将棋・囲碁における機械学習活用
コンピュータ将棋・囲碁における機械学習活用Takashi Kato
 
バンディット問題の理論とアルゴリズムとその実装
バンディット問題の理論とアルゴリズムとその実装バンディット問題の理論とアルゴリズムとその実装
バンディット問題の理論とアルゴリズムとその実装EinosukeIida
 
GiNZAで始める日本語依存構造解析 〜CaboCha, UDPipe, Stanford NLPとの比較〜
GiNZAで始める日本語依存構造解析 〜CaboCha, UDPipe, Stanford NLPとの比較〜GiNZAで始める日本語依存構造解析 〜CaboCha, UDPipe, Stanford NLPとの比較〜
GiNZAで始める日本語依存構造解析 〜CaboCha, UDPipe, Stanford NLPとの比較〜Megagon Labs
 
PRML 4.1 Discriminant Function
PRML 4.1 Discriminant FunctionPRML 4.1 Discriminant Function
PRML 4.1 Discriminant FunctionShintaro Takemura
 
アルゴリズムイントロダクション15章 動的計画法
アルゴリズムイントロダクション15章 動的計画法アルゴリズムイントロダクション15章 動的計画法
アルゴリズムイントロダクション15章 動的計画法nitoyon
 
駒場学部講義2019 「統合失調症、感覚運動随伴性、自由エネルギー原理」
駒場学部講義2019 「統合失調症、感覚運動随伴性、自由エネルギー原理」駒場学部講義2019 「統合失調症、感覚運動随伴性、自由エネルギー原理」
駒場学部講義2019 「統合失調症、感覚運動随伴性、自由エネルギー原理」Masatoshi Yoshida
 
論文紹介 Anomaly Detection using One-Class Neural Networks (修正版
論文紹介 Anomaly Detection using One-Class Neural Networks (修正版論文紹介 Anomaly Detection using One-Class Neural Networks (修正版
論文紹介 Anomaly Detection using One-Class Neural Networks (修正版Katsuki Ohto
 
深層学習 勉強会第5回 ボルツマンマシン
深層学習 勉強会第5回 ボルツマンマシン深層学習 勉強会第5回 ボルツマンマシン
深層学習 勉強会第5回 ボルツマンマシンYuta Sugii
 
Empirical Study Incorporating Linguistic Knowledge on Filled Pauses for Pers...
Empirical Study Incorporating Linguistic Knowledge on Filled Pausesfor Pers...Empirical Study Incorporating Linguistic Knowledge on Filled Pausesfor Pers...
Empirical Study Incorporating Linguistic Knowledge on Filled Pauses for Pers...Yuta Matsunaga
 
Crfと素性テンプレート
Crfと素性テンプレートCrfと素性テンプレート
Crfと素性テンプレートKei Uchiumi
 

Was ist angesagt? (20)

MIRU2020長尾賞受賞論文解説:Attention Branch Networkの展開
MIRU2020長尾賞受賞論文解説:Attention Branch Networkの展開MIRU2020長尾賞受賞論文解説:Attention Branch Networkの展開
MIRU2020長尾賞受賞論文解説:Attention Branch Networkの展開
 
大規模凸最適化問題に対する勾配法
大規模凸最適化問題に対する勾配法大規模凸最適化問題に対する勾配法
大規模凸最適化問題に対する勾配法
 
(文献紹介)深層学習による動被写体ロバストなカメラの動き推定
(文献紹介)深層学習による動被写体ロバストなカメラの動き推定(文献紹介)深層学習による動被写体ロバストなカメラの動き推定
(文献紹介)深層学習による動被写体ロバストなカメラの動き推定
 
パターン認識と機械学習6章(カーネル法)
パターン認識と機械学習6章(カーネル法)パターン認識と機械学習6章(カーネル法)
パターン認識と機械学習6章(カーネル法)
 
形状解析のための楕円フーリエ変換
形状解析のための楕円フーリエ変換形状解析のための楕円フーリエ変換
形状解析のための楕円フーリエ変換
 
「3.1.2最小二乗法の幾何学」PRML勉強会4 @筑波大学 #prml学ぼう
「3.1.2最小二乗法の幾何学」PRML勉強会4 @筑波大学 #prml学ぼう 「3.1.2最小二乗法の幾何学」PRML勉強会4 @筑波大学 #prml学ぼう
「3.1.2最小二乗法の幾何学」PRML勉強会4 @筑波大学 #prml学ぼう
 
지적 대화를 위한 깊고 넓은 딥러닝 PyCon APAC 2016
지적 대화를 위한 깊고 넓은 딥러닝 PyCon APAC 2016지적 대화를 위한 깊고 넓은 딥러닝 PyCon APAC 2016
지적 대화를 위한 깊고 넓은 딥러닝 PyCon APAC 2016
 
モバイル向けEdgeTPUの紹介
モバイル向けEdgeTPUの紹介モバイル向けEdgeTPUの紹介
モバイル向けEdgeTPUの紹介
 
深層ニューラルネットワークの積分表現(Deepを定式化する数学)
深層ニューラルネットワークの積分表現(Deepを定式化する数学)深層ニューラルネットワークの積分表現(Deepを定式化する数学)
深層ニューラルネットワークの積分表現(Deepを定式化する数学)
 
コンピュータ将棋・囲碁における機械学習活用
コンピュータ将棋・囲碁における機械学習活用コンピュータ将棋・囲碁における機械学習活用
コンピュータ将棋・囲碁における機械学習活用
 
バンディット問題の理論とアルゴリズムとその実装
バンディット問題の理論とアルゴリズムとその実装バンディット問題の理論とアルゴリズムとその実装
バンディット問題の理論とアルゴリズムとその実装
 
GiNZAで始める日本語依存構造解析 〜CaboCha, UDPipe, Stanford NLPとの比較〜
GiNZAで始める日本語依存構造解析 〜CaboCha, UDPipe, Stanford NLPとの比較〜GiNZAで始める日本語依存構造解析 〜CaboCha, UDPipe, Stanford NLPとの比較〜
GiNZAで始める日本語依存構造解析 〜CaboCha, UDPipe, Stanford NLPとの比較〜
 
PRML 4.1 Discriminant Function
PRML 4.1 Discriminant FunctionPRML 4.1 Discriminant Function
PRML 4.1 Discriminant Function
 
アルゴリズムイントロダクション15章 動的計画法
アルゴリズムイントロダクション15章 動的計画法アルゴリズムイントロダクション15章 動的計画法
アルゴリズムイントロダクション15章 動的計画法
 
駒場学部講義2019 「統合失調症、感覚運動随伴性、自由エネルギー原理」
駒場学部講義2019 「統合失調症、感覚運動随伴性、自由エネルギー原理」駒場学部講義2019 「統合失調症、感覚運動随伴性、自由エネルギー原理」
駒場学部講義2019 「統合失調症、感覚運動随伴性、自由エネルギー原理」
 
論文紹介 Anomaly Detection using One-Class Neural Networks (修正版
論文紹介 Anomaly Detection using One-Class Neural Networks (修正版論文紹介 Anomaly Detection using One-Class Neural Networks (修正版
論文紹介 Anomaly Detection using One-Class Neural Networks (修正版
 
深層学習 勉強会第5回 ボルツマンマシン
深層学習 勉強会第5回 ボルツマンマシン深層学習 勉強会第5回 ボルツマンマシン
深層学習 勉強会第5回 ボルツマンマシン
 
Empirical Study Incorporating Linguistic Knowledge on Filled Pauses for Pers...
Empirical Study Incorporating Linguistic Knowledge on Filled Pausesfor Pers...Empirical Study Incorporating Linguistic Knowledge on Filled Pausesfor Pers...
Empirical Study Incorporating Linguistic Knowledge on Filled Pauses for Pers...
 
Crfと素性テンプレート
Crfと素性テンプレートCrfと素性テンプレート
Crfと素性テンプレート
 
SGDによるDeepLearningの学習
SGDによるDeepLearningの学習SGDによるDeepLearningの学習
SGDによるDeepLearningの学習
 

Mehr von Kobkrit Viriyayudhakorn

Chochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service RobotChochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service RobotKobkrit Viriyayudhakorn
 
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...Kobkrit Viriyayudhakorn
 
Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Kobkrit Viriyayudhakorn
 
Check Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching PresentationCheck Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching PresentationKobkrit Viriyayudhakorn
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)Kobkrit Viriyayudhakorn
 
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)Kobkrit Viriyayudhakorn
 
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)Kobkrit Viriyayudhakorn
 
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.Kobkrit Viriyayudhakorn
 
Lecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationLecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationKobkrit Viriyayudhakorn
 
Unity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidUnity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidKobkrit Viriyayudhakorn
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2Kobkrit Viriyayudhakorn
 
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Kobkrit Viriyayudhakorn
 
Lecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityLecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityKobkrit Viriyayudhakorn
 
Lecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingLecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingKobkrit Viriyayudhakorn
 
Lecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-NativeLecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-NativeKobkrit Viriyayudhakorn
 
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)Kobkrit Viriyayudhakorn
 

Mehr von Kobkrit Viriyayudhakorn (20)

Thai E-Voting System
Thai E-Voting System Thai E-Voting System
Thai E-Voting System
 
Thai National ID Card OCR
Thai National ID Card OCRThai National ID Card OCR
Thai National ID Card OCR
 
Chochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service RobotChochae Robot - Thai voice communication extension pack for Service Robot
Chochae Robot - Thai voice communication extension pack for Service Robot
 
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
 
Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)Thai Text processing by Transfer Learning using Transformer (Bert)
Thai Text processing by Transfer Learning using Transformer (Bert)
 
How Emoticon Affects Chatbot Users
How Emoticon Affects Chatbot UsersHow Emoticon Affects Chatbot Users
How Emoticon Affects Chatbot Users
 
Check Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching PresentationCheck Raka Chatbot Pitching Presentation
Check Raka Chatbot Pitching Presentation
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
 
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)[Lecture 4] AI and Deep Learning: Neural Network (Theory)
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
 
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
 
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
 
Lecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase AuthenticationLecture 12: React-Native Firebase Authentication
Lecture 12: React-Native Firebase Authentication
 
Unity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and AndroidUnity Google VR Cardboard Deployment on iOS and Android
Unity Google VR Cardboard Deployment on iOS and Android
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
 
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
 
Lecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityLecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in Unity
 
Lecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR ProgrammingLecture 1 Introduction to VR Programming
Lecture 1 Introduction to VR Programming
 
Thai Word Embedding with Tensorflow
Thai Word Embedding with Tensorflow Thai Word Embedding with Tensorflow
Thai Word Embedding with Tensorflow
 
Lecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-NativeLecture 3 - ES6 Script Advanced for React-Native
Lecture 3 - ES6 Script Advanced for React-Native
 
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
 

หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)

  • 1. หัวใจของปัญญาประดิษฐ์(A.I.) และความน่าตื่นเต้นของ Deep Learning ดร. กอบกฤตย์ วิริยะยุทธกร kobkrit@iapp.co.th บริษัท ไอแอพพ์เทคโนโลยี จำกัด http://ai.iapp.co.th
  • 3. General AI & Narrow AI • General AI ปัญญาประดิษฐ์ทั่วไป • Narrow AI ปัญญาประดิษฐ์แบบแคบ วำงแผน เข้ำใจภำษำ รู้จำวัตถุ รู้จำเสียง สำมำรถเรียนรู้ได้ด้วยตัวเอง แก้ปัญหำได้ A.I. 3
  • 6. ปัญญาประดิษฐ์สร้างได้อย่างไร • เขียนโปรแกรมด้วยมนุษย์(Manual Program) • อย่ำงเช่นเขียนโปรแกรมให้ค้นหำคำตอบที่ดีสุดจำกคำตอบทั้งหมด โดยใช้ประโยชน์จำกควำมเร็วของเครื่อง • คนเขียนบอกวิธีให้หมด ไม่จำเป็นต้องใช้ข้อมูลในกำรเรียนรู้ AI 6
  • 7. ปัญญาประดิษฐ์สร้างได้อย่างไร • ใช้เทคนิคการเรียนรู ้ด้วยเครื่อง (Machine Learning) • คนไม่ต้องเขียนโปรแกรมบอกทุกขั้นตอน ให้คอมพิวเตอร์สำมำรถเรียนรู้จำกข้อมูลได้ด้วยตัวเอง • ต้องใช้ข้อมูลมหำศำล AI 7
  • 8. การเรียนรู ้ด้วยเครื่อง (Machine Learning) • คือหนทำงที่ทำให้คอมพิวเตอร์ฉลำดจำกกำรที่สำมำรถเรียนรู้ได้ด้วยตัวเอง • เป็นหนทำงหลักของกำรสร้ำงปัญญำประดิษฐ์ในปัจจุบัน • โจทย์ A.I. นั้นยำกและซับซ้อนเกินว่ำที่มนุษย์จะเขียนโปรแกรมออกมำได้ • ต้องใช้ข้อมูล (Data) จำนวนมำก (Big Data) เพื่อให้คอมพิวเตอร์สำมำรถหำควำมสัมพันธ์ระหว่ำงข้อมูลนำเข้ำ (Input) และคำตอบ (Output) ได้อัตโนมัติ ML 8
  • 10. ML 10
  • 17. Anomaly Detection Kobkrit Viriyayudhakorn Location: BKK Age: 32 Job Role: Data Scientist Time/Date Shop Location Channel Amount 25 Nov 13:29 Fuji Restaurant Bangkok POS THB350.78 25 Nov 14:01 Asia Book Bangkok POS THB150 25 Nov 14:02 Dermstore Saint Petersburg POS 60000 Russian ruble -> 29,905.02 THB 25 Nov 19.07 Google Ads Singapore Internet 215 SGD -> 5,171.67 THB อันไหนเป็ น Fraud? Credit Card Statement ML 17
  • 19. Autonomous Car Actions: Reward: จานวน KM ที่เข้าใกล้เชียงใหม่มากขึ้น +1 จานวนเวลาที่ใช้ต่อนาที -0.001 ทาผิดกฏจราจร -100 เกิดอุบัติเหตุ -999999 กรุงเทพ เชียงใหม่ 700km Environment: Observation: ML 19
  • 21. วิธีการสร้าง Label Dataset เพื่อ Machine Learning มนุษย์ใช้ไม้บรรทัดวัด Features = X Output = Y ML Feature Engineering Structure Data 21
  • 22. Machine Learning ทางานอย่างไร x (Input) y (Output) 0 1 1 3 2 5 3 7 ????x y หัวใจของปัญญาประดิษฐ์Gradient Descent 22
  • 23. Machine Learning ทางานอย่างไร x (Input) y (Output) 0 1 1 3 2 5 3 7 y=2x+1x y หัวใจของปัญญาประดิษฐ์Gradient Descent 23
  • 24. Machine Learning ทางานอย่างไร x (Input) y (Output) 0 1 1 3 2 5 3 7 y=ax+bx y ใบ้คอมพิวเตอร ์ให้ว่าเป็ นสมการเส้นตรง*นะ * เพื่อความง่ายต่อการเข้าใจ จริงๆแล้วมี ML สามารถรับรองสมการได้ทุกรูปแบบ หัวใจของปัญญาประดิษฐ์Gradient Descent 24
  • 25. การคาดเดา h (Prediction) ค่ำ h คือคำตอบที่เกิดจำก กำรเดำจำก a และ b คำนวณโดย h = ax +b กาหนดให้ค่า ค่ำ y คือคำตอบที่ถูกต้อง x (Input) y (Output) 0 1 1 3 2 5 3 7 • สมมุติ A.I. เดำค่ำมำว่ำค่ำ a = 1 ค่ำ b = 0.5 • ในแถวแรกค่ำ x = 0, y = 1 • ค่ำ h = ax + b = 1*0 + 0.5 = 0.5 • เมื่อเทียบกับ y = 1 A.I. ยังเดำค่ำผิดไป 0.5 ** สนใจเฉพำะแถวแรกก่อน ** หัวใจของปัญญาประดิษฐ์Gradient Descent 25
  • 26. • วิธีกำรคำนวณควำมแตกต่ำงระหว่ำงค่ำจริง (y) กับค่ำที่เรำเดำ (h) ในแต่ละแถวข้อมูล เรียกว่ำ Lost Function • ค่ำ Lost ยิ่งเยอะยิ่งเดำผิด ถ้ำ Lost = 0 ก็จะเดำถูกหมดเลย • Lost Function ที่ง่ำยที่สุดในแวบแรกคือ = 𝒚 − 𝒉 • แต่ใช้ไม่ได้จริง เพรำะถ้ำ y ติดลบ จะไม่สำมำรถใช้ได้ • ดังนั้น Lost Function ที่ง่ำยที่สุดๆ (จริง) คือ • แต่เพื่อควำมง่ำยในกำรคำนวณ Derivative จึงใส่ 1/2 ไปข้ำงหน้ำด้วย Lost Function หัวใจของปัญญาประดิษฐ์Gradient Descent 26 (𝒚 − 𝒉) 𝟐 𝟏 𝟐 (𝒚 − 𝒉) 𝟐
  • 27. Cost Function x (Input) y (Output) h (Predict) Lost Value 0 1 0.5 0.125 1 3 1.5 1.125 2 5 2.5 3.125 3 7 3.5 6.125 Cost (Sum) 10.5 • h = ax +b โดยที่เรำเดำสุ่มมำว่ำ a = 1 และ b = 0.5, h = 1x + 0.5 • Lost Function = • Cost คือผลรวมของ Error ทั้งหมดของ Data ในที่ใช้ในกำร Train = 10.5 • Cost function (Sum of Square Error, SSE) = = 10.5 หัวใจของปัญญาประดิษฐ์Gradient Descent 27 𝒊=𝟏 𝒏 𝟏 𝟐 (𝒚𝒊 − 𝒉𝒊) 𝟐
  • 28. สรุปการเดารอบแรก • หำกเรำเดำ a = 1 และ b = 0.5 ในรอบแรก • เรำจะผลรวมค่ำผิดพลำด (Cost Value) = 21 • เรำต้องกำรที่จะให้ผลรวมค่ำผิดพลำดลดลงให้มำกที่สุด (Cost Value) = 0 เพื่อให้โมเดลทำงำนได้อย่ำงถูกต้อง เรำ จะต้องทำอย่ำงไร?? • เรำก็ต้องปรับค่ำกำรเดำ a และ b ใหม่สิ ให้มันถูกต้องมำกยิ่งขึ้น หัวใจของปัญญาประดิษฐ์Gradient Descent 28
  • 29. วิธีการเดาแบบเป็ นระบบ • แน่นอนวิธีกำรเดำเป็นระบบก็ต้องลองลดหรือเพิ่มตัวแปรทีละตัว • ลองเปลี่ยนแปลงค่ำ a ดูก่อน แต่เดิม a = 1 • หำกเรำลด a ไป 0.1 => 1.0 - 0.1 = 0.9 • หำกเรำเพิ่ม a ไป 0.1 => 1.0 + 0.1 = 1.1 - - a ++ 10 2 หัวใจของปัญญาประดิษฐ์Gradient Descent 29
  • 30. x (Input) y (Output) h (Predict) Lost Value 0 1 0.5 0.125 1 3 1.4 1.28 2 5 2.3 3.645 3 7 3.2 7.22 Cost (Sum) 12.27 • h = ax +b โดยที่ a = 0.9 และ b = 0.5 ลองลด a ลง 0.1 (จากเดิม 1) หัวใจของปัญญาประดิษฐ์Gradient Descent 30
  • 31. x (Input) y (Output) h (Predict) Error Value 0 1 0.5 0.125 1 3 1.6 0.98 2 5 2.7 2.645 3 7 3.8 5.12 Cost (Sum) 8.87 • h = ax +b โดยที่ a = 1.1 และ b = 0.5 ลองเพิ่ม a ขึ้น 0.1 (จากเดิม 1) หัวใจของปัญญาประดิษฐ์Gradient Descent 31
  • 32. x (Input) y (Output) h (Predict) Error Value 0 1 0.4 0.18 1 3 1.4 1.28 2 5 2.4 3.38 3 7 3.4 6.48 Cost (Sum) 11.32 • h = ax +b โดยที่ a = 1 และ b = 0.4 ลองลด b ลง 0.1 (จากเดิม 0.5) หัวใจของปัญญาประดิษฐ์Gradient Descent 32
  • 33. x (Input) y (Output) h (Predict) Error Value 0 1 0.6 0.08 1 3 1.6 0.98 2 5 2.6 2.88 3 7 3.6 5.78 Cost (Sum) 9.72 • h = ax +b โดยที่ a = 1 และ b = 0.6 ลองเพิ่ม b ขึ้น 0.1 (จากเดิม 0.5) หัวใจของปัญญาประดิษฐ์Gradient Descent 33
  • 34. ค่า Cost Value เปลี่ยนแปลงไปตามค่าของ a,b 10.5 10.9 1.1 12.27 8.87 Total Error ค่าของ a 10.5 0.50.4 0.6 11.32 9.72 Total Error ค่าของ b 2 1 หัวใจของปัญญาประดิษฐ์Gradient Descent 34
  • 35. การเดาแบบมีระบบ • กำรเดำแบบมีระบบพอบอกเรำได้ว่ำต้องปรับ a, b ไปยังทิศทำงใดเพื่อให้ Cost Value ได้ต่ำที่สุด • แต่โจทย์ของเรำง่ำยมำก มีแค่ 2 ตัวแปร หำกใช้เวลำไม่นำนก็น่ำจะหำคำตอบได้ เนื่องจำกเฉลยของเรำยังเป็นเบอร์ที่ลงตัวง่ำย อีกด้วย (a = 2, b =1) • แต่โจทย์ AI จริงๆนั้น มีตัวแปรแบบ a,b ถึง 100 ล้ำนตัวแปร แล้วตัวเลขที่ดีที่สุดของแต่ละตัวแปรที่ต้องคำดเดำไปเรื่อยๆ โดย ที่ไม่รู้ว่ำต้องปรับค่ำในปริมำณสัดส่วนเท่ำไร • นอกจำกนี้ตัวแปรแต่ละตัวก็ล้วนมีควำมสัมพันธ์กันทำให้กำรเปลี่ยนค่ำตัวนึง ภำยใต้ค่ำตัวแปรอีกตัวนึงก็มีผลที่แตกต่ำงกัน ส่งผลต่อค่ำ Cost Value ที่แตกต่ำงกันอีกด้วย หัวใจของปัญญาประดิษฐ์Gradient Descent 35
  • 36. การเดาแบบมีระบบ ดี แต่ยังใช้ไม่ได้ในโจทย์จริง 768 px 1024 px • จำกรูปแมว 1 รูปมีขนำด 1024 x 768 = 786,432 Pixel • แล้วแต่ละ Pixel มีค่ำสีได้ถึง 16 ล้ำนสี • กำรจะหำตัวแปรเพื่อให้ Cost Function Value ที่ใช้ใน กำรแยกแยะแมวหรือสุนัขต่ำที่สุด อำจจะต้องใช้กำรคำนวณ มำกถึง • ln2(786,43216,000,000) คำสั่ง • ใช้เวลำชั่วนิรันด์ในกำรคำนวณด้วยคอมพิวเตอร์ในยุคปัจจุบัน หัวใจของปัญญาประดิษฐ์Gradient Descent 36
  • 37. ขั้นตอนการเรียนรู ้ด้วย Gradient Descent • เรำมีวิธีที่ดีกว่ำกำรเดำไปเรื่อยๆ ต้องขอบคุณที่เรำมี Calculus Cost function A B • Gradient Descent ทำให้เรำสำมำรถ รู้ว่ำเรำต้องปรับค่ำไปทำงไหนแต่ละตัวแปรในสัดส่วนเท่ำไร แล้วทำ ให้ค่ำ Cost function วิ่งเข้ำหำจุดที่ต่ำที่สุดตำม Slope ที่ชัน ที่สุด • ใช้เทคนิคคล้ำยๆกับกำรเดำแบบมีระบบแต่เรำสำมำรถค่ำสัดส่วนที่ เหมำะสม (วิ่งหำ Slope ที่ชันที่สุด) ได้ทันที Leibniz Newton หัวใจของปัญญาประดิษฐ์Gradient Descent 37
  • 38. • Calculus คือกำรหำควำมชัน • สมุมติว่ำเรำพิจำรณำ A ก่อน หา d(y)/d(x) = ถ้า x = 1, ความชัน = 2(1-2) = -2 ถ้า x = 3 ความชัน = 2(3-2) = 2 x=1 x=3 Cost function A B หัวใจของปัญญาประดิษฐ์Gradient Descent 38
  • 39. • Cost function (Sum of Square Error) = • กำรปรับค่ำ a และ b ที่ดีที่สุดก็คือหำค่ำ Slope ของ a และ b บน Cost Function • Slope ของ a = วิธีการหาค่าที่เหมาะสมสาหรับการปรับค่า a, b Cost function A B 𝜕(𝑆𝑆𝐸) 𝜕(𝑎) = 𝜕 𝑆𝑆𝐸 𝜕(ℎ) 𝜕(ℎ) 𝜕(𝑎) 𝒊=𝟏 𝒏 𝟏/𝟐 𝒚𝒊 − 𝒉𝒊 2 𝜕 𝑆𝑆𝐸 𝜕(ℎ) = 𝜕( 𝑖=1 𝑛 1/2 𝑦𝑖 −ℎ𝑖 2) 𝜕 (ℎ) = - 𝑦𝑖 − ℎ𝑖 𝜕(ℎ) 𝜕(𝑎) = 𝜕( 𝑎𝑥+𝑏) 𝜕 (𝑎) = x 𝝏(𝑺𝑺𝑬) 𝝏(𝒂) = - 𝒚𝒊 − 𝒉𝒊 𝐱 Slope ของ b = 𝜕(𝑆𝑆𝐸) 𝜕(𝑏) = 𝜕 𝑆𝑆𝐸 𝜕(ℎ) 𝜕(ℎ) 𝜕(𝑏) 𝜕(ℎ) 𝜕(𝑏) = 𝜕( 𝑎𝑥+𝑏) 𝜕 (𝑏) = 1 𝝏(𝑺𝑺𝑬) 𝝏(𝒃) = - 𝒚𝒊 − 𝒉𝒊 หัวใจของปัญญาประดิษฐ์Gradient Descent 39
  • 40. วิธีการหา Cost ที่ต่าที่สุดด้วย Gradient Descent 1. มั่วค่ำ a,b ขึ้นมำค่ำนึง 2. คำนวณค่ำ Cost function (Sum of Square Error) 3. คำนวณหำ Slope ของ a = 𝝏(𝑺𝑺𝑬) 𝝏(𝒂) , b = 𝝏(𝑺𝑺𝑬) 𝝏(𝒃) ที่ชันที่สุด 4. เปลี่ยนค่ำ a = a − 𝛼 𝝏(𝑺𝑺𝑬) 𝝏(𝒂) และ b = b − 𝛼 𝝏(𝑺𝑺𝑬) 𝝏(𝒃) 5. ทำ 2-4 ไปเรื่อยจนค่ำ Cost function เข้ำใกล้ 0 หรือในจุดที่เรำพอใจ 𝛼 = Learning Rate มักจะเป็ นค่าน้อย มากๆ (0.001) เพื่อ ไม่ให้มันลง Slope เร็ว เกินไป (เดี๋ยวเลย) หัวใจของปัญญาประดิษฐ์Gradient Descent 40
  • 42. Gradient Descent Step-by-Step #1 • h = ax +b โดยที่ a = 1.0 และ b = 0.5 𝝏(𝑺𝑺𝑬) 𝝏(𝒂) = - 𝒚𝒊 − 𝒉𝒊 𝐱 = -17 𝝏(𝑺𝑺𝑬) 𝝏(𝒃) = - 𝒚𝒊 − 𝒉𝒊 = -8 𝛼 = 0.01 x (Input) y (Output) h (Predict) Error -(y-h) -(y-h)x 0 1 0.5 0.125 -0.5 0 1 3 1.5 1.125 -1.5 -1.5 2 5 2.5 3.125 -2.5 -5 3 7 3.5 6.125 -3.5 -10.5 Sum 10.5 -8 -17 a = a − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒂 = 𝟏 − 𝟎. 𝟎𝟏 −𝟏𝟕 = 𝟏. 𝟏𝟕 b = b − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒃 = 𝟎. 𝟓 − 𝟎. 𝟎𝟏 −𝟖 = 𝟎. 𝟓𝟖 หัวใจของปัญญาประดิษฐ์Gradient Descent 42
  • 43. Gradient Descent Step-by-Step #2 • h = ax +b โดยที่ a = 1.17 และ b = 0.58 𝝏(𝑺𝑺𝑬) 𝝏(𝒂) = - 𝒚𝒊 − 𝒉𝒊 𝐱 = -14.14 𝝏(𝑺𝑺𝑬) 𝝏(𝒃) = - 𝒚𝒊 − 𝒉𝒊 = -6.66 𝛼 = 0.01 x (Input) y (Output) h (Predict) Lost Value -(y-h) -(y-h)x 0 1 0.58 0.0882 -0.42 0 1 3 1.75 0.78125 -1.25 -1.25 2 5 2.92 2.1632 -2.08 -4.16 3 7 4.09 4.23405 -2.91 -8.73 Sum 7.2667 -6.66 -14.14 a = a − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒂 = 𝟏. 𝟏𝟕 − 𝟎. 𝟎𝟏 −𝟏𝟒. 𝟏𝟒 = 𝟏. 𝟑𝟏 b = b − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒃 = 𝟎. 𝟓𝟖 − 𝟎. 𝟎𝟏 −𝟔. 𝟔𝟔 = 𝟎. 𝟔𝟓 หัวใจของปัญญาประดิษฐ์Gradient Descent 43
  • 44. Gradient Descent Step-by-Step #3 • h = ax +b โดยที่ a = 1.31 และ b = 0.65 𝝏(𝑺𝑺𝑬) 𝝏(𝒂) = - 𝒚𝒊 − 𝒉𝒊 𝐱 = -11.76 𝝏(𝑺𝑺𝑬) 𝝏(𝒃) = - 𝒚𝒊 − 𝒉𝒊 = -5.54 𝛼 = 0.01 x (Input) y (Output) h (Predict) Lost Value -(y-h) -(y-h)x 0 1 0.65 0.06125 -0.35 0 1 3 1.96 0.5408 -1.04 -1.04 2 5 3.27 1.49645 -1.73 -3.46 3 7 4.58 2.9282 -2.42 -7.26 Sum 5.0267 -5.54 -11.76 a = a − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒂 = 𝟏. 𝟒𝟐 b = b − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒃 = 𝟎. 𝟕𝟎 หัวใจของปัญญาประดิษฐ์Gradient Descent 44
  • 45. Gradient Descent Step-by-Step #4 • h = ax +b โดยที่ a = 1.42 และ b = 0.70 𝝏(𝑺𝑺𝑬) 𝝏(𝒂) = - 𝒚𝒊 − 𝒉𝒊 𝐱 = -9.92 𝝏(𝑺𝑺𝑬) 𝝏(𝒃) = - 𝒚𝒊 − 𝒉𝒊 = -4.68 𝛼 = 0.01 x (Input) y (Output) h (Predict) Lost Value -(y-h) -(y-h)x 0 1 0.7 0.045 -0.3 0 1 3 2.12 0.3872 -0.88 -0.88 2 5 3.54 1.0658 -1.46 -2.92 3 7 4.96 2.0808 -2.04 -6.12 Sum 3.5788 -4.68 -9.92 a = a − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒂 = 𝟏. 𝟓𝟏 b = b − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒃 = 𝟎. 𝟕𝟒 หัวใจของปัญญาประดิษฐ์Gradient Descent 45
  • 46. ทาไปเรื่อยๆถึงรอบที่ 25 1 รอบ = 1 epoch หัวใจของปัญญาประดิษฐ์Gradient Descent 46
  • 47. Gradient Descent Step-by-Step #25 • h = ax +b โดยที่ a = 2.004 และ b = 0.973 𝝏(𝑺𝑺𝑬) 𝝏(𝒂) = - 𝒚𝒊 − 𝒉𝒊 𝐱 = -0.09 𝝏(𝑺𝑺𝑬) 𝝏(𝒃) = - 𝒚𝒊 − 𝒉𝒊 = -0.07 𝛼 = 0.01 x (Input) y (Output) h (Predict) Lost Value -(y-h) -(y-h)x 0 1 0.973631 0.000348 -0.02637 0 1 3 2.978477 0.000232 -0.02152 -0.021523 2 5 4.983323 0.000139 -0.01668 -0.033354 3 7 6.988169 7E-05 -0.01183 -0.035492 Sum 0.000788 -0.0764 -0.090369 a = a − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒂 = 𝟐. 𝟎𝟎𝟓 b = b − 𝛼 𝝏 𝑺𝑺𝑬 𝝏 𝒃 = 𝟎. 𝟗𝟕𝟒 หัวใจของปัญญาประดิษฐ์Gradient Descent 47
  • 48. ในที่สุด A.I. ก็ค้นพบคาตอบ x (Input) y (Output) 0 1 1 3 2 5 3 7 y=2.005x+0.974x y หัวใจของปัญญาประดิษฐ์Gradient Descent y=2x+1x y 48
  • 49. แต่ยัง ยังไม่จบ This is just the beginning นี่แหละคือ Gradient Descent นี่คือหัวใจของ A.I. ทั้งมวล A.I.และ Machine Learning ทุกตัวสร้ำง จำกพื้นฐำนของ Gradient Descent ทั้งหมด ยินดีด้วย หำกท่ำนเข้ำใจ Gradient Descent ถือว่ำท่ำนเข้ำใจหัวใจของ A.I. แล้ว 49 หัวใจของปัญญาประดิษฐ์ Gradient Descent
  • 50. เทคนิคทาง Machine Learning • Linear Regression คือสิ่งที่พึ่งได้เรียนไป 50 Supervised Learning ML
  • 51. เทคนิคทาง Machine Learning • Logistic Regression คือเทคนิคกำรแบ่งแยกข้อมูลเป็น 2 Class 51 Supervised Learning ML
  • 52. เทคนิคทาง Machine Learning • Linear Discriminant Analysis คือเทคนิคกำรแบ่งแยกข้อมูลมำกกว่ำ 2 Class 52 Supervised Learning ML
  • 53. เทคนิคทาง Machine Learning • Classification and Regression Trees กำรแบ่งแยกแบบตัดสินใจเป็นชั้นๆ 53 Supervised Learning ML
  • 54. เทคนิคทาง Machine Learning • Naive Bayes: กำรแบ่งแยกแบบตัดสินใจตำมหลักควำมเป็นไปได้แบบมีเงื่อนไข (Conditional Probability) 54 Supervised Learning ML
  • 55. เทคนิคทาง Machine Learning • Support Vector Machine คือเทคนิคกำรแบ่งแยกข้อมูลมำกกว่ำ 2 Class ที่สนใจในกำรวำดเส้นตัดสินใจระหว่ำง 2 Class ให้ กว้ำงที่สุดเท่ำที่ทำได้ และมีเทคนิคกำรแปลง Space ข้อมูล (Kernel Method) เป็นเทคนิค ML ที่แม่นยำและยอดนิยมที่สุด ก่อน ยุค Deep Learning 55 Supervised Learning ML
  • 56. เทคนิคทาง Machine Learning • Neural Network: สำมำรถจับควำมสัมพันธ์และแบ่งแยกได้อย่ำงยอดเยี่ยม และเป็นพื้นฐำนสำคัญของ AI ยุคใหม่ (Deep Learning) 56 Supervised Learning ML
  • 57. เทคนิคทาง Machine Learning • K-nearest Neighbors: จับกลุ่มข้อมูลด้วยดูจำกควำมใกล้ของ Features 57 Unsupervised Learning ML
  • 58. เทคนิคทาง Machine Learning • Random Forest: คือเทคนิคกำรให้ ML หลำยๆตัว รับข้อมูลไม่เท่ำกันและช่วยกัน Vote ในกำรตัดสินใจ ถือว่ำเป็น เทคนิคกำรรวมกลุ่มกันช่วยแบบนึง (Ensemble Learning) ทำให้ควำมแม่นยำสูงขึ้นกว่ำ Train Model เดี่ยวๆ 58 Unsupervised Learning ML
  • 59. เทคนิคทาง Machine Learning • Adaboost: คือเทคนิคกำรให้ ML หลำยๆตัว โดยให้ตัวใหม่แก้ไขข้อผิดพลำดของตัวเก่ำไปเรื่อยๆ ถือว่ำเป็นเทคนิคกำร รวมกลุ่มกันช่วยแบบนึง (Ensemble Learning) ทำให้ควำมแม่นยำสูงขึ้นกว่ำ Train Model เดี่ยวๆ 59 Unsupervised Learning ML
  • 67. ทาไม Deep Learning ถึงสาเร็จ 67 DL
  • 69. การเก็บข้อมูลสาหรับ Deep Learning • เพื่อที่จะได้ข้อมูลที่ครบถ้วนที่สุด Deep Learning ที่ไม่ต้องให้มนุษย์มำทำกำร Feature Engineer ให้อีกต่อไป ตัว Deep Learning จะเป็นคนคัดเลือก Feature ให้เอง • Machine Learning : ทำ Classifer ประเภทดอกไม้ คนที่คิดว่ำอะไรเป็นตัวที่แสดงควำมแตกต่ำงของแต่ละ ประเภทดอกไม้แล้ว ไปวัดด้วยไม้บรรทัดแล้วแล้ว กรอกเป็นข้อมูลเข้ำไป • Deep Learning: ถ่ำยรูปดอกไม้ส่งเข้ำไป Classifer เลย • มีควำมแม่นยำสูงกว่ำ Machine Learning อย่ำงเห็นได้ชัด • ต้องกำรข้อมูลและพลังกำรคำนวณมำกขึ้น 69 DL
  • 70. วิธีการสร้าง Label Dataset เพื่อ Machine Learning มนุษย์ใช้ไม้บรรทัดวัด Features = X Output = Y Feature Engineering Structure Data 70 DL
  • 71. วิธีการสร้าง Label Dataset เพื่อ Deep Learning Unstructured Data 71 DL
  • 73. 73 DL
  • 74. Neural Network: Root of Deep Learning 74 DL
  • 75. Neural Network: Human Brain Cell 75 DL
  • 76. Neural Network: Activation Function 76 DL
  • 78. 78 DL
  • 79. 79
  • 83. 83 DL
  • 85. Image Captioning: CNN + RNN 85 DL
  • 91. 91 DL
  • 93. สรุป • ปัญญำประดิษฐ์เรียนรู้โลกผ่ำนข้อมูลที่ข้อมูลมนุษย์ใส่เข้ำไป • ปัญญำประดิษฐ์ จริงๆแล้ว มันไม่ใช่ Magic อะไร เป็นเพียงแค่หลักการคานวณทางคณิตศาสตร ์เพื่อสามารถลดความ ผิดพลาดไปเรื่อยๆเท่านั้น (Gradient Descent) ซึ่งเป็ นหัวใจของ AI • ปัญญำประดิษฐ์ยังไม่เข้ำใจหรอกว่ำตัวเองกำลังทำอะไรอยู่และไม่รู้ตัวด้วย (ยังไม่มีสติ) เหมือนกับกล้ำมเนื้อหัวใจที่เต้นเพรำะมีกระแสไฟฟ้ำสั่ง ยังไม่สำมำรถ ควบคุมตัวเองได้ จังหวะที่ปัญญำประดิษฐ์จะมีสติแล้วสำมำรถพัฒนำตัวเองได้เองเรียกว่ำ Singularity • ปัญญำประดิษฐ์ยังขำดด้ำนความคิดสร้างสรรค์และยังขำดความเข้าใจมนุษย์ • ปัญญำประดิษฐ์กำลังเติบโตจำกโลกงำนวิจัย มำยังโลกธุรกิจที่จับต้องได้ และเข้ำถึงทุกคนมำกขึ้นเรื่อยๆ มันจะพัฒนำให้ ดีขึ้น เร็วขึ้น และลดต้นทุน ได้มหาศาล • ปัญญำประดิษฐ์จะเปลี่ยนแปลงกำรทำงำนของมนุษย์ โดยที่งานที่ทาซ้าๆ จะถูกทดแทนด้วย A.I. มากขึ้นเรื่อยๆ 93
  • 94. Q/A • ลองเล่น AI ฝีมือคนไทย • http://ai.iapp.co.th 94
  • 95. Reference • https://www.slideshare.net/LuMa921/deep-learning-a-visual-introduction • https://www.slideshare.net/mahutte/introduction-to-statistical-machine-learning-14028152 • https://www.deeplearningbook.org/ • https://github.com/cstorm125/thai2vec • http://web.stanford.edu/class/cs20si/syllabus.html • https://www.wolframalpha.com • https://www.kdnuggets.com/2017/04/simple-understand-gradient-descent-algorithm.html • https://towardsdatascience.com/a-tour-of-the-top-10-algorithms-for-machine-learning-newbies-dde4edffae11 95