Pengant engantar ar Deep Learning untuk NLP Alfan Farizki Farizki Wicaksono (
[email protected])
Information Retrieval Lab. Fakul akulta tass Ilmu Ilmu Kompu ompute ter r Unive Universita rsitass Indonesia Indonesia 2017
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
1
Deep Learning Tsunami Learning waves have lapped at the shores of “Deep Le comput computati ational onal linguist linguistics ics fo forr sever several al years now, now, but 2015 2015 seems like the year when the full force of the tsunami hit the major Natural Natural Language Processing Processing (NLP) conferen conferences. ces.” -Dr Dr.. Christ Christopher opher D. Mann Manning, ing, Dec 2015
Christopher D. Manning. (2015). Computational Linguistics and Deep Learning Computational Linguistics, 41(4), 701 –707.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
2
Tips Sebelum mempelajari RNNs dan arsitektur Deep Learning yang lainnya, disarankan untuk kita mempelajari beberapa topik berikut: •
Gradient Descent/Ascent
•
Linear Regression
•
Logistic Regression
•
Konsep Backpropagation Backpropagation dan Computational Computational Graph
•
Multilayer Multilayer Neural Networks
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
3
Referensi/Bacaan •
Andrej Karpathy’ Blog •
•
Colah’s Blog •
•
http://karpathy.github.io/2015/05/21/rnn-effectiveness/ http://karpathy.github.io/2015/05/21/rnn-effectiveness/
Buku Deep Learning Yoshua Bengio •
Y. Bengio, Deep Learning, MLSS 2015
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
4
Deep Learning vs Machine Learning •
Deep Learning adalah bagian dari isu Machine Learning
•
Machine Learning adalah bagian dari isu Artificial Intelligence
Artificial Intelligence • •
•
Searching Knowledge Representation and reasoning Planning
Machine Learning
Deep Learning
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
5
Machine Learning
: Dirancang manusia
(rule-based)
: Di-infer otomatis
Predicted label: positive
Hand-crafted rules:
if contains(‘menarik’): return positive ...
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
6
“Buku ini sangat menarik dan penuh manfaat ”
Machine Learning
: Dirancang manusia
(classical ML)
: Di-infer otomatis
Fungsi klasifikasi dioptimasi berdasarkan input (fitur) & ouput. Predicted label: positive
Learn mapping from features to label
Classifier
Feature Engineering! Hand-designed Feature Extractor: Contoh: Menggunakan TF-IDF, informasi syntax dengan POS Tagger, dsb.
Representation
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
7
“Buku ini sangat menarik dan penuh manfaat ”
Machine Learning
: Dirancang manusia
(Representation Learning)
: Di-infer otomatis
Fitur dan fungsi klasifikasi di-optimasi secara bersama-sama. Predicted label: positive
Learn mapping from features to label
Learn Feature Extractor Contoh: Restricted Boltzman Machine, Autoencoder, dsb.
Classifier
Representation
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
8
“Buku ini sangat menarik dan penuh manfaat ”
Machine Learning
: Dirancang manusia
(Deep Learning)
: Di-infer otomatis
Deep Learning learns Features!
7 1 0 2 r e b o t c O 9
Predicted label: positive
Learn mapping from features to label
Classifier
Fitur yang Lebih High Level Fitur Kompleks/High-Level Fitur Sederhana
Representation
I U M O K L I S A F , o n o s k a c i W . F n a f l A
9
“Buku ini sangat menarik dan penuh manfaat ”
Sejarah
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
10
The Perceptron (Rosenblatt, 1958) •
•
Sejarah dimulai dimulai dengan Perceptron di akhir tahun 1950. Perceptron terdiri dari 3 layer: Sensory, Association, dan Response.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
http://www.andreykurenkov.com/writing/a-brief-history-of-neural-nets-and-deep-learning/ Rosenblatt, Frank. “The perceptron: a probabilistic model for information storage and
11
The Perceptron (Rosenblatt, 1958) 7 1 0 2 r e b o t c O 9
Learning perceptron menggunakan metode Donald Hebb.
I U M O K L I S A F , o n o s k a c i W . F n a f l A
Saat itu, mampu melakukan klasifikasi untuk input Pixel 20x20!
12
Activation function adalah fungsi non-linier. Dalam kasus perceptron Rosenblatt, activation function adalah operasi thresholding biasa (step function).
http://www.andreykurenkov.com/writing/a-brief-history-of-neural-nets-and-deep-learning/ The organization of behavior: A neuropsychological theory. D. O. Hebb. John Wiley
The Fathers of Deep Learning(?) 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
13
The Fathers of Deep Learning(?) •
•
•
•
•
•
Di tahun 2006, ketiga orang tersebut mengembangkan cara untuk memanfaatkan dan mengatasi masalah training terhadap deep neural networks. Sebelumnya, banyak orang yang sudah menyerah terkait manfaat dari neural network, dan cara training-nya. Mereka mengatasi masalah terkait Neural Network belum mampu belajar untuk menemukan representasi yang berguna. Geoff Hinton has been snatched up by Google; Yann LeCun is Director of AI Research at Facebook; Yoshua Bengio holds a position as research chair for Artificial Intelligence at University of Montreal
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
14
The Fathers of Deep Learning(?) •
Automated learning of data representations and features is what the hype is all about!
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
15
Mengapa sebelumnya “deep learning” tidak sukses? •
•
•
Sebenarnya, neural network kompleks sudah banyak ditemukan sebelumnya. Bahkan Long-Short Term Memory (LSTM) network, yang saat ini ramai digunakan di bidang NLP, ditemukan tahun 1997 oleh Hochreiter & Schmidhuber. Ditambah lagi, orang dahulu percaya bahwa neural network “can solve everything!”. Tetapi, mengapa mereka tidak bisa melakukannya dahulu?
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
16
Mengapa sebelumnya “deep learning” tidak sukses? •
Beberapa alasan, oleh Ilya Sutskever: •
•
•
•
http://yyue.blogspot.co.id/2015/01/a-brief-overview-of-deeplearning.html
Computers were slow. So the neural networks of past were tiny. And tiny neural networks cannot achieve very high performance on anything. In other words, small neural networks are not powerful . Datasets were small. So even if it was somehow magically possible to train LDNNs, there were no large datasets that had enough information to constrain their numerous parameters. So failure was inevitable. Nobody knew how to train deep nets. The current best object recognition networks have between 20 and 25 successive layers of convolutions. A 2 layer neural network cannot do anything good on object recognition. Yet back in the day everyone was very sure that deep nets cannot be trained with SGD , since that would’ve been too good to be true
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
17
The Success of Deep Learning Salah satu faktor-nya adalah karena saat ini ditemukan cara learning yang bekerja secara praktikal. The success of Deep Learning hinges on a very fortunate fact: that well-tuned and carefully-initialized stochastic gradient descent (SGD) can train LDNNs on problems that occur in practice. It is not a trivial fact since the training error of a neural network as a function of its weights is highly non-convex. And when it comes to nonconvex optimization , we were taught that all bets are off ... And yet, somehow, SGD seems to be very good at training those large deep neural networks on the tasks that we care about. The problem of training neural networks is NP-hard , and in fact there exists a family of datasets such that the problem of finding the best neural network with three hidden units is NP-hard . And yet, SGD just solves it in practice. Ilya Sutskever, http://yyue.blogspot.co.at/2015/01/a-brief-overview-of-deep-learning.html
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
18
7 1 0 2 r e b o t c O 9
Apa Itu Deep Learning?
I U M O K L I S A F , o n o s k a c i W . F n a f l A
19
Apa itu Deep Learning? •
•
Kenyataannya, Deep Learning = (Deep) Artificial Neural Networks (ANNs) Dan Neural Networks sebenarnya Tumpukan Fungsi Matematika
adalah
sebuah
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
20 Image Courtesy: Google
Apa itu Deep Learning? Secara praktis, (supervised) Machine Learning itu adalah: Ekspresikan permasalahan ke dalam sebuah fungsi F (yang mempunyai parameter θ), lalu secara otomatis cari parameter θ sehingga fungsi F tepat mengeluarkan output yang diinginkan. Predicted label: Y = positive
Y = F(X; θ)
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
21
X: “Buku ini sangat menarik dan penuh manfaat ”
Apa itu Deep Learning? Untuk Deep Learning, fungsi tersebut biasanya terdiri dari tumpukan banyak fungsi yang biasanya serupa.
Y
F ( F ( F ( X ; 3 ); 2 ); 1 ) Y = positive
F(X; θ3)
Gambar ini sering disebut dengan istilah Computational Graph
F(X; θ2)
Tumpukan Fungsi ini sering disebut dengan Tumpukan Layer
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
F(X; θ1)
22 “Buku ini sangat menarik dan penuh manfaat ”
Apa itu Deep Learning? •
Layer yang paling terkenal/umum adalah Fully-Connected Layer.
7 1 0 2 r e b o t c O 9
Y F ( X ) f (W . X b) •
•
“weighted sum of its inputs, followed by a non-linear function” Fungsi non-linier yang umum digunakan: Tanh (tangent hyperbolic), Sigmoid, ReLU (Rectified Linear Unit) M N
W R
M unit X R N unit
f
N
f
M
b R
w x i
f (W . X b) X
i
wi xi b
i
I U M O K L I S A F , o n o s k a c i W . F n a f l A
b
23
i
Non-linearity
Mengapa perlu “Deep”? •
•
•
•
Humans organize their ideas and concepts hierarchically Humans first learn simpler concepts and then compose them to represent more abstract ones Engineers break-up solutions into multiple levels of abstraction and processing It would be good to automatically learn / discover these concepts
Y. Bengio, Deep Learning, MLSS 2015, Austin, Texas, Jan 2014 (Bengio & Delalleau 2011)
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
24
Neural Networks Y f (W 1. X b1 )
X
Y f (W 1. X b1 )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
25
Neural Networks Y f (W 1.( f (W 1. X b2 )) b1 )
Y f (W 2 . H 1 b2 )
X
H 1
f (W 1. X b1 )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
26
Neural Networks Y f (W 1.( f (W 2 .( f (W 3 . X b3 )) b2 )) b1 )
Y f (W 3 . H 2 b3 )
X
H 1
f (W 1. X b1 ) H 2
f (W 2 . H 1 b2 )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
27
Alasan matematis mengapa harus “deep”? “deep”? •
•
A neural network with a single hidden layer of enough units can units can approximate approximate an any y co conti ntinu nuou ouss fu func ncti tion on arbitrarily arbitrarily well. In ot othe herr wor ords ds,, it can can solv solve e whate hatev ver prob proble lem m you’re interested in!
(Cyb (C yben enk ko 19 1998 98,, Ho Horn rnik ik 19 1991 91))
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
28
Alasan matematis mengapa harus “deep”? “deep”? Akan tetapi ... •
•
•
•
“Enough units” can be a very large number. There are functions repr re prese esent ntabl able e with with a smal small, l, bu butt de dee ep netw networ ork k that that woul would d require exponentially man many unit unitss with with a sing single le lay layer er.. The proof only only says that a shallow network network exists, exists, it does not say how to find it. Evidence indicates that it is easier to train a deep network to perf perfor orm m well ell than than a sha halllow low one ne.. A more recent result brings an example of a very large class of functions that cannot be efficiently represented with a smalldepth network.
(e.g., (e.g ., Ha Hast stad ad et al al.. 198 986 6, Be Beng ngio io & Del ela all llea eau u 201 011) 1) (Brave (Bra verman, rman, 2011 2011))
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
29
Mengapa perlu non-linearity ?
f
f w x i
i
wi xi b
i
b
i
Non-linearity Mengapa perlu fungsi non-linier f ? H 1
W 1. X b1
H 2
W 2 . H 1 b2
Y W 3 . H 2
?
b3
Kalau tanpa f , rangkaian fungsi ini adalah tetap fungsi linier. Data bisa sangat kompleks, dan terkadang hubungan yang ada pada data tidak hanya linier, tetapi bisa non-linier. Perlu representasi yang bisa menangkap hal ini.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
30
Training Neural Networks Y f (W 1.( f (W 2 .( f (W 3 . X b3 )) b2 )) b1 ) •
•
Secara random, kita inisialisasi semua parameter W1, b1, W2, b2, W3, b3 Definisikan sebuah cost function/loss function yang mengukur seberapa baik fungsi neural network Anda. •
•
Seberapa jauh nilai yang diprediksi dengan nilai sesungguhnya
Secara iteratif/berulang-ulang, sesuaikan nilai parameter sehingga nilai loss function menjadi minimal.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
31
Training Neural Networks •
W(3)
W(2)
Initialize trainable parameters randomly
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
W(1) Buku ini sangat baik dan mendidik
32
Training Neural Networks •
•
Initialize trainable parameters randomly Loop: x = 1 → #epoch: •
W(3)
W(2)
Pick a training example
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
W(1) x
Buku ini sangat baik dan mendidik
33
Training Neural Networks True Label
y’
pos
neg
1
0
•
•
Pred. Label (Output)
y
Initialize trainable parameters randomly Loop: x = 1 → #epoch: •
0.3
0.7
•
W(3) h2 W(2) h1
Pick a training example Compute output by doing feedforward process
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
W(1) x
Buku ini sangat baik dan mendidik
34
Training Neural Networks True Label
y’
pos
neg
1
0
•
L
•
y
Pred. Label (Output)
y
0.3
Initialize trainable parameters randomly Loop: x = 1 → #epoch: •
0.7
•
W(3)
•
h2 W(2) h1
Pick a training example Compute output by doing feedforward process Compute gradient of loss w.r.t. output
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
W(1) x
Buku ini sangat baik dan mendidik
35
Training Neural Networks True Label
y’
pos
neg
1
0
•
L
•
y
Pred. Label (Output)
y
0.3
•
L ( 3)
•
L h2
•
W(2) h1 W(1) x
Loop: x = 1 → #epoch: •
0.7 W
Initialize trainable parameters randomly
Buku ini sangat baik dan mendidik
Pick a training example Compute output by doing feedforward process Compute gradient of loss w.r.t. output Backpropagate loss, computing gradients w.r.t trainable parameters. It’s like computing contribution of error to the output of each parameter
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
36
Training Neural Networks True Label
y’
pos
neg
1
0
•
L y
Pred. Label (Output)
y
0.3
0.7 L W
Loop: x = 1 → #epoch: •
•
( 3) •
L h2
L W ( 2 )
L h1 W(1) x
•
Initialize trainable parameters randomly
Buku ini sangat baik dan mendidik
•
Pick a training example Compute output by doing feedforward process Compute gradient of loss w.r.t. output Backpropagate loss, computing gradients w.r.t trainable parameters. It’s like computing contribution of error to the output of each parameter
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
37
Training Neural Networks True Label
y’
pos
neg
1
0
•
L
•
y
Pred. Label (Output)
y
0.3
•
L ( 3)
•
L h2
L h1
L
•
W ( 2 ) L W
x
Loop: x = 1 → #epoch: •
0.7 W
Initialize trainable parameters randomly
(1)
Buku ini sangat baik dan mendidik
Pick a training example Compute output by doing feedforward process Compute gradient of loss w.r.t. output Backpropagate loss, computing gradients w.r.t trainable parameters. It’s like computing contribution of error to the output of each parameter
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
38
Gradient Descent (GD) Take small step in direction of negative gradient! ( t 1) n
( t ) n
t
( t ) n
f ( ( t ) )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
39 https://github.com/joshdk/pygradesc
Lebih Detail dalam Hal Teknis …
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
40
Gradient Descent (GD) Salah satu framework paling sederhana untuk permasalahan optimasi (multivariate optimization). Digunakan untuk mencari konfigurasi parameter-parameter sehingga cost function menjadi optimal, dalam hal ini mencapai local minimum. GD menggunakan metode iteratif , yang dimulai dari sebuah titik acak, dan secara perlahan-lahan mengikuti arah negatif dari gradient sehingga pada akhirnya akan berpindah ke suatu titik kritikal, yang diharapkan merupakan local minimum.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
41
Tidak dijamin mencapai global minimum !
Gradient Descent (GD) Problem: carilah nilai x sehingga fungsi f(x) = 2x4 + x3 – 3x2 mencapai titik local minimum. 7 1 0 2 r e b o t c O 9
Misal, kita pilih x dimulai dari x=2.0:
Algoritma GD konvergen pada titik x = 0.699, yang merupakan local minimum.
Local minimum
I U M O K L I S A F , o n o s k a c i W . F n a f l A
42
Gradient Descent (GD) Algorithm:
For t 1, 2, ..., N max : xt 1 xt t f ' ( xt )
If f ' ( xt 1 )
If xt xt 1
then return " converged on critical po int" then return " converged on x value"
If f ( xt 1 ) f ( xt ) then return " diverging "
αt : learning rate atau step size pada iterasi ke-t ϵ: sebuah bilangan yang sangat kecil Nmax: batas banyaknya iterasi, atau disebut epoch jika iterasi selalu sampai akhir Algoritma dimulai dengan menebak nilai x1 ! Tips: pilih α yang tidak terlalu kecil, juga tidak terlalu besar
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
43
Gradient Descent (GD) Kalau parameter-nya ada banyak ? Carilah θ = θ1, θ2, …, θn sehingga f( θ1, θ2, …, θn) mencapai local minimum !
while not converged : ( t 1) 1
( t ) 1
( t 1) 2
( t ) 2
t
t
( t ) 1
( t )
2
( t )
f ( ) f ( (t ) )
( t 1) n
( t ) n
t
( t )
n
f ( (t ) )
Dimulai dengan menebak nilai awal θ = θ1, θ2, …, θn
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
44
Gradient Descent (GD) Take small step in direction of negative gradient! ( t 1) n
( t ) n
t
( t ) n
f ( ( t ) )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
45 https://github.com/joshdk/pygradesc
Logistic Regression Berbeda dengan Linear Regression, Logistic Regression digunakan untuk permasalahan Binary Classification. Jadi output yang dihasilkan adalah diskrit ! (1 atau 0), (ya atau tidak). Misal, diberikan 2 hal: 1. Unseen data x yang ingin diprediksi labelnya, yaitu y . 2. Model logistic regression dengan parameter θ0, θ 1, … , θ n yang sudah ditentukan. n
P ( y 1 | x; ) ( 0 1 x1 ... n xn ) ( 0 i xi ) i 1
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
P ( y 0 | x; ) 1 P ( y 1 | x; ) 46 ( z )
1 1
z
Logistic Regression Bisa digambarkan dalam bentuk “single neuron”. n
P ( y 1 | x; ) ( 0 1 x1 ... n xn ) ( 0 i xi ) i 1
P ( y 0 | x; ) 1 P ( y 1 | x; )
( z )
1 1 e
z
x1 x2 x3
θ1 θ2 θ3 θ0
+1 Dengan fungsi sigmoid sebagai activation function
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
47
Logistic Regression Slide sebelumnya mengasumsikan bahwa parameter θ sudah ditentukan. Bagaimana bila belum ditentukan ? Kita bisa estimasi parameter θ dengan memanfaatkan training data {(x(1), y(1)), (x(2), y(2)), …, (y(n), y(n))} yang diberikan (learning). x1 x2 x3 +1
θ1
θ2 θ3
θ0
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
48
Logistic Regression Learning Misal, n
h ( x) ( 0 1 x1 ... n xn ) ( 0
x ) i
i
i 1
Probabilitas masing-masing kelas dapat dituliskan secara singkat (persamaan di slide-slide sebelumnya) dengan: P ( y | x; ) (h ( x)) y .(1 h ( x))1
y
y {0,1}
Diberikan m buah training examples, likelihood: m
L( ) P ( y ( i ) | x ( i ) ; )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
i 1 m
y ( i )
( h ( x )) (i )
i 1
.(1 h ( x (i ) ))1 y
(i )
49
Logistic Regression Learning Dengan MLE, kita akan mencari konfigurasi parameter yang memberikan nilai likelihood maksimal (= nilai log-likelihood maksimal). l ( ) log L( ) m
y
(i )
log h ( x (i ) ) (1 y (i ) ) log (1 h ( x ( i ) ))
i 1
Atau, kita cari parameter yang meminimalkan fungsi negative log-likelihood (cross-entropy loss). Inilah cost function kita !
m
J ( ) y (i ) log h ( x (i ) ) (1 y ( i ) ) log (1 h ( x (i ) )) i 1
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
50
Logistic Regression Learning Agar bisa menggunakan Gradient Descent untuk mencari parameter yang meminimalkan cost function, kita perlu menurunkan: i
J ( )
Dapat ditunjukkan bahwa untuk sebuah training example (x,y): j
J ( ) (h ( x) y ) x j
Jadi, untuk update nilai parameter di tiap iterasi untuk semua example: m
j : j
(i ) (i ) i ( h ( x ) y ) x j i 1
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
51
Logistic Regression Learning Batch Gradient Descent untuk learning model 7 1 0 2 r e b o t c O 9
θ1, θ2, …, θn
inisialisasi
while not converged : m
1 : 1
(h
(i )
(i )
i 1
( x ) y ) x
i 1 m
2 : 2
(i ) (i ) i ( h ( x ) y ) x 2 i 1
m
n : n
(h
( x ( i ) ) y (i ) ) xni
I U M O K L I S A F , o n o s k a c i W . F n a f l A
i 1
52
Logistic Regression Learning Stochastic Gradient Descent: kita bisa membuat progress dan update parameter ketika kita melihat sebuah training example. inisialisasi
θ1, θ2, …, θn
while not converged : for i := 1 to m do : 1 : 1
2
( y
(i )
:
2
( y
(i )
:
n
( y
(i )
h ( x (i ) )) x1i
h ( x ( i ) )) x2i
h ( x (i ) )) xni
n
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
53
Logistic Regression Learning Mini-Batch Gradient Descent untuk learning model: Daripada kita gunakan sebuah sample untuk update (seperti online learning), gradient dihitung dengan cara rata-rata/sum dari sebuah minibatch sample (misal, 32 atau 64 sample). Batch Gradient Descent : gradient dihitung untuk semua sample! •
Untuk sekali step, terlalu besar komputasinya
Online Learning: gradient dihitung untuk sebuah sample! •
•
Terkadang noisy Update step sangat kecil
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
54
Multilayer Neural Network (Multilayer Perceptron) Logistic Regression sebenarnya bisa dianggap sebagai Neural Network dengan beberapa unit di la yer input , satu unit di layer output , dan tanpa hidden layer . x1 x2 x3
θ1 θ2 θ3 θ0
+1
Dengan fungsi sigmoid sebagai activation function
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
55
Multilayer Neural Network (Multilayer Perceptron) Misal, ada 3-layer NN, dengan 3 input unit, 2 hidden unit, dan 2 output unit. (1)
x1
11 (1)
(2)
21
11 (2)
21
(1)
12
x2
(2)
12
(1) 22
(2)
22
(1)
13
(1)
(2) 1
23
x3
(1) 1
(2)
2
(1)
2
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
+1 56
+1
W(1), W(2), b(1), b(2) adalah parameter !
Multilayer Neural Network (Multilayer Perceptron) Seandainya parameter sudah diketahui, bagaimana caranya memprediksi label dari input (klasifikasi) ? Dari contoh sebelumnya, ada 2 unit di output layer. Kondisi ini biasanya digunakan untuk binary classification. Unit pertama menghasilkan probabilitas untuk pertama, dan unit kedua menghasilkan probabilitas untuk kelas kedua. Kita perlu melakukan proses feed-forward untuk menghitung nilai yang dihasilkan di output layer.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
57
Multilayer Neural Network (Multilayer Perceptron) Misal, untuk activation function, kita gunakan fungsi hyperbolic tangent . f ( x) tanh( x)
Untuk menghitung output di hidden layer: ( 2) (1) (1) (1) (1) z 1 W 11 x1 W 12 x2 W 13 x3 b1
z 2
( 2)
(1) (1) (1) (1) W 21 x1 W 22 x2 W 23 x3 b2
a1( 2)
f ( z 1( 2) )
a2( 2)
f ( z 2( 2) )
Ini hanyalah perkalian matrix !
W z W x b W ( 2)
(1)
(1)
(1) 11 (1) 21
(1) 12 (1) 22
W W
x1 W b1(1) x2 (1) W b2 x (1) 13 (1) 23
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
58
Multilayer Neural Network (Multilayer Perceptron) Jadi, Proses feed-forward secara keseluruhan hingga menghasilkan output di kedua output unit adalah:
z ( 2)
W (1) x b (1)
a ( 2)
f ( z ( 2 ) )
z (3)
W ( 2) a ( 2 ) b ( 2)
hW ,b ( x) a (3)
softmax ( z (3) )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
59
Multilayer Neural Network (Multilayer Perceptron) Learning Ada Cost function yang berupa cross-entropy loss: 7 1 0 2 r e b o t c O 9
m adalah banyaknya training examples.
J (W , b)
1 m
m
yi , j log( pi , j ) i 1
j
nl 1 sl
2
l 1 i 1 j 1
sl 1
( l ) 2 ( W ji )
Regularization terms
Berarti, cost function untuk satu sample (x,y) adalah:
J (W , b; x, y )
j
y j loghW ,b ( x j )
j
y j log p j
I U M O K L I S A F , o n o s k a c i W . F n a f l A
60
Multilayer Neural Network (Multilayer Perceptron) Learning Namun, kali ini, Cost function kita adalah squared-error: 7 1 0 2 r e b o t c O 9
m adalah banyaknya training examples.
nl 1 sl
I U M O K L I S A F , o n o s k a c i W . F n a f l A
2 1 (i ) ( i ) ( l ) 2 J (W , b) hW ,b ( x ) y W ( ji ) m i 1 2 2 l 1 i 1 j 1
1
m
sl 1
Regularization terms
Berarti, cost function untuk satu sample (x,y) adalah:
J (W , b; x, y )
1 2
(i )
hW ,b ( x ) y
(i )
2
1
hW ,b ( x j 2 j
(i )
) y j
(i ) 2
61
Multilayer Neural Network (Multilayer Perceptron) Learning Batch Gradient Descent
inisialisasi W, b while not converged : ( l ) ij
W
bi(l )
( l ) ij
W
( l )
bi
( l ) ij
W ( l ) i
b
Bagaimana cara menghitung gradient ??
J (W , b)
J (W , b)
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
62
Multilayer Neural Network (Multilayer Perceptron) Learning Misal, (x, y) adalah sebuah training sample, dan dJ(W,b;x,y) adalah turunan parsial terkait sebuah sample (x,y). dJ(W,b;x,y) menentukan overall partial derivative dJ(W,b):
1 m (i ) (i ) ( l ) ( , ) ( , ; , ) J W b J W b x y W ij ( l ) W ij(l ) m W i 1 ij
1
bi
m
J (W , b) ( l )
m
b i 1
(i ) (i ) ( , ; , ) J W b x y ( l )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
i
63 Dihitung dengan teknik BackPropagation
Multilayer Neural Network (Multilayer Perceptron) Learning Back-Propagation 1. Jalankan proses feed-forward 2. Untuk setiap output unit i pada layer nl (output layer) (n ) i l
( nl )
J (W , b; x, y ) (ai ( nl ) z i
( nl )
yi ) f ' ( z i
)
3. l = nl - 1, nl - 2, ... 2 Untuk setiap node i di layer l ( l ) i
sl 1
( W ji j ( l )
( l 1)
) f ' ( z i(l ) )
j 1
4. Finally..
( l ) ( l 1) ( , ; , ) J W b x y a j i ( l ) W ij
( l 1) J ( W , b ; x , y ) i ( l )
bi
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
64
Multilayer Neural Network (Multilayer Perceptron) Learning Back-Propagation
(2) 12 (2) 22
Contoh hitung gradient di output ... J (W , b; x, y ) J ( 3) 1
a
( 3) 1 ( 3) 1
a
z
a
( 3) 1
1 2
y1
a
( 3) 1
y1
2
z
1 2
a
( 3)
( 2) W 12
( 2) a2
y2
(3)
1
(3)
2
(3)
2
2
(2)
(2) 1
2
+1 ( 3) 1
( 2) 12
W
( 3) ( 2) ( 2) ( 2) ( 2) ( 2) z 1 W 11 a1 W 12 a2 b1
z 1
( 3) 2
f z f ' z ( 3) 1 ( 3) 1
(3)
1
(2) 11 (2) 21
J (W , b; x, y )
( 3)
J ( 3) 1
a
a
( 3) 1
a1
( 3) 1
z
( 3)
z 1
( 2)
W 12 ( 3)
y1 f ' ( z 1
) a2( 2 )
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
65
Sensitivity – Jacobian Matrix The Jacobian J is the matrix of partial derivatives of the network output vector y with respect to the input vector x.
. . J . .
. . . .
. . . .
. . . .
J k i ,
yk xi
These derivatives measure the relative sensitivity of the outputs to small changes in the inputs, and can therefore be used, for example, to detect irrelevant inputs.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
66
More Complex Neural Networks (Neural Network Architectures) Recurrent Neural Networks (Vanilla RNN, LSTM, GRU) Attention Mechanisms Recursive Neural Networks
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
67
Recurrent Neural Networks O1
O2
O3
O4
O5 7 1 0 2 r e b o t c O 9
h1
h2
X1
h3
X2
h5
h4
X3
I U M O K L I S A F , o n o s k a c i W . F n a f l A
X4
X5
One of the famous Deep Learning Architectures in the NLP community
68
Recurrent Neural Networks (RNNs) Kita biasanya menggunakan RNNs untuk: Memproses Sequences Menghasilkan Sequences … Intinya … ada Sequences •
•
•
•
Sequences biasanya: Urutan kata-kata Urutan kalimat-kalimat Signal Suara Video (Sequence of Images) … •
•
•
•
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
•
•
69
Recurrent Neural Networks (RNNs) Not RNNs (Vanilla Feed-Forward NNs)
Sequence Input (e.g. Sentence Classification)
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
Sequence Output (e.g. Image Captioning)
Sequence Input/Output (e.g. Machine Translation)
70
Recurrent Neural Networks (RNNs)
RNNs combine the input vector with their state vector with a fixed (but learned) function to produce a new state vector. This can, in programming terms, be interpreted as running a fixed program with certain inputs and some internal variables. In fact, it is known that RNNs are Turing-Complete in the sense that they can simulate arbitrary programs (with proper weights).
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
71 http://binds.cs.umass.edu/papers/1995_Siegelmann_Science.pdf http://karpathy.github.io/2015/05/21/rnn-effectiveness/
Recurrent Neural Networks (RNNs) Misal, ada I input unit, K output unit, dan H hidden unit (state). Y1
Komputasi RNNs untuk satu sample:
Y2
ht R
W
(hy )
W
s1 W W
s2
( xh )
H 1
R
H I
yt R
( hh )
R
( hh )
st 1
W
H H
W ( hy ) R K H
( hh )
( xh )
ht
W
( xh )
xt W
st tanh ht
X1
I 1
xt R
X2
yt
h0
W ( hy ) st
0
K 1
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
72
Recurrent Neural Networks (RNNs) Back Propagation Through Time (BPTT) Y1
The loss function depends on the activation of the hidden layer not only through its influence on the output layer.
Y2
( y ) (h) i ,t
s1
s2
K ( hy ) ( y ) H ( hh ) ( h ) W i , j j ,t W i ,n n ,t 1 f ' hi ,t n 1 j 1
(h)
Di output:
( y ) i ,t
Lt yi ,t
Di setiap step, kecuali paling kanan: X1
X2
(h) i ,t
Lt hi ,t
(h)
i ,T 1
0
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
73
Recurrent Neural Networks (RNNs) Back Propagation Through Time (BPTT) Y1
The same weights are reused at every timestep, we sum over the whole sequence to get the derivatives with respect to the network weights.
Y2
W (hy )
L s1 W
W
s2
( hh )
W i , j
j ,t si ,t 1 (h)
t 1
( hh )
L
( xh )
( hy )
W i , j
L X1
T
X2
( xh )
W i , j
T
j ,t si ,t ( y )
t 1
T
j ,t xi ,t
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
(h)
t 1
74
Recurrent Neural Networks (RNNs) Back Propagation Through Time (BPTT) 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
75
Recurrent Neural Networks (RNNs) Back Propagation Through Time (BPTT) Term-term ini disebut temporal contribution: bagaimana W(hh) pada step k mempengaruhi cost pada step-step setelahnya ( t > k )
Misal, untuk parameter antar state:
W
ht hk
( hh )
t
Lt
Lt ht hk ( hh ) h h W k 1 t k
ht
ht 1
ht 1 ht 2
hk 2
hk ( hh )
W
t k Diputus sampai k step ke belakang. Di sini artinya “immediate derivative”, yaitu hk-1 dianggap konstan terhadap W(hh).
hk 1
hk 1
1
hk
W
( xh )
( hh )
xt W ( hh )
W
st 1
s
t 1
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
76
Recurrent Neural Networks (RNNs) Vanishing & Exploding Gradient Problems Bengio et al., (1994) said that “the exploding gradients problem refers to the large increase in the norm of the gradient during training. Such events are caused by the explosion of the long term components, which can grow exponentially more then short term ones.” And “The vanishing gradients problem refers to the opposite behaviour, when long term components go exponentially fast to norm 0, making it impossible for the model to learn correlation between temporally distant events.” Kok bisa terjadi? Coba lihat salah satu temporal component dari sebelumnya:
ht hk
ht ht 1
ht 1
hk 2 hk 1 ht 2 hk 1 hk
In the same way a product of t - k real numbers can shrink to zero or explode to infinity, so does this product of Matrices. ( Pascanu et al.,) Bengio, Y., Simard, P., and Frasconi, P. (1994). Learning long-term dependencies with gradient
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
77
Recurrent Neural Networks (RNNs) Vanishing & Exploding Gradient Problems
Sequential Jacobian biasa digunakan untuk analisis penggunaan konteks pada RNNs. 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
78
Recurrent Neural Networks (RNNs) Solusi untuk Vanishing Gradient Problem 1) Penggunaan non-gradient based training algorithms (Simulated Annealing, Discrete Error Propagation, etc.) (Bengio et al., 1994) 2) Definisikan arsitektur baru di dalam RNN Cell!, seperti Long-Short Term Memory (LSTM) (Hochreiter & Schmidhuber, 1997). 3) Untuk metode yang lain, silakan merujuk (Pascanu et al., 2013).
Pascanu et al., On the difficulty of training Recurrent Neural Networks, 2013 S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. Neural Computation,9(8):1735 1780, 1997 Y. Bengio, P. Simard, and P. Frasconi. Learning Long-Term Dependencies with Gradient
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
79
Recurrent Neural Networks (RNNs) Variant: Bi-Directional RNNs 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
80
Recurrent Neural Networks (RNNs) Sequential Jacobian (Sensitivity) untuk Bi-Directional RNNs
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
81
Long-Short Term Memory (LSTM) 1. The LSTM architecture consists of a set of recurrently connected subnets, known as memory blocks. 2. These blocks can be thought of as a differentiable version of the memory chips in a digital computer. 3. Each block contains: 1.
Self-connected memory cells
2. Three multiplicative units (gates) 1.
Input gates (analogue of write operation)
2.
Output gates (analogue of read operation)
3.
Forget gates ((analogue of reset operation))
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
82 S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. Neural Computation,9(8):1735
Long-Short Term Memory (LSTM)
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
83 Alex Graves, Supervised Sequence Labelling with Recurrent Neural Networks S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. Neural Computation,9(8):1735
Long-Short Term Memory (LSTM) The multiplicative gates allow LSTM memory cells to store and access information over long periods of time, thereby mitigating the vanishing gradient problem.
For example, as long as the input gate remains closed (i.e. has an activation near 0), the activation of the cell will not be overwritten by the new inputs arriving in the network, and can therefore be made available to the net much later in the sequence, by opening the output gate.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
84 Alex Graves, Supervised Sequence Labelling with Recurrent Neural Networks S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. Neural Computation,9(8):1735
Long-Short Term Memory (LSTM) Visualisasi lain dari satu cell di LSTM 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
85 S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. Neural Computation,9(8):1735
Long-Short Term Memory (LSTM) Komputasi di LSTM 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
86 S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. Neural Computation,9(8):1735
Long-Short Term Memory (LSTM) Preservation of Gradient Information pada LSTM
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
87 Alex Graves, Supervised Sequence Labelling with Recurrent Neural Networks S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. Neural Computation,9(8):1735
Example: RNNs for POS Tagger (Zennaki, 2015) PRP
h1
VBD
JJ
TO
h2
h3
NN
I U M O K L I S A F , o n o s k a c i W . F n a f l A
h5
h4
7 1 0 2 r e b o t c O 9
88 I
went
to
west
java
LSTM + CRF for Semantic Role Labeling (Zhou and Xu, ACL 2015)
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
89
Attention Mechanism
A potential issue with this encoder –decoder approach is that a neural network needs to be able to compress all the necessary information of a source sentence into a fixed-length vector. This may make it difficult for the neural network to cope with long sentences, especially those that are longer than the sentences in the training corpus. Dzmitry Bahdanau, et al., Neural machine translation by jointly learning to align and translate, 2015
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
90
Attention Mechanism Neural Translation Model TANPA Attention Mechanism 7 1 0 2 r e b o t c O 9
Sutkever, Ilya et al., Sequence to Sequence Learning with Neural Networks, NIPS 2014.
I U M O K L I S A F , o n o s k a c i W . F n a f l A
91
https://blog.heuritech.com/2016/01/20/attention-mechanism/
Attention Mechanism Neural Translation Model TANPA Attention Mechanism
Sutkever, Ilya et al., Sequence to Sequence Learning with Neural Networks, NIPS 2014.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
92
Attention Mechanism Mengapa Perlu Attention Mechanism? •
•
Each time the proposed model generates a word in a translation, it (soft-)searches for a set of positions in a source sentence where the most relevant information is concentrated. The model then predicts a target word based on the context vectors associated with these source positions and all the previous generated target words.
… it encodes the input sentence into a sequence of vectors and chooses a subset of these vectors adaptively while decoding the translation. This frees a neural translation model from having to squash all the information of a source sentence, regardless of its length, into a fixed-length vector.
Dzmitry Bahdanau, et al., Neural machine translation by jointly learning to align and translate, 2015
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
93
https://blog.heuritech.com/2016/01/20/attention-mechanism/
Attention Mechanism Neural Translation Model – dengan Attention Mechanism 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
94 Dzmitry Bahdanau, Kyunghyun Cho, Yoshua Bengio, Neural Machine Translation by Jointly
Attention Mechanism Neural Translation Model – dengan Attention Mechanism 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
Cell merepresentasikan bobot attention, terkait translation. Dzmitry Bahdanau, Kyunghyun Cho, Yoshua Bengio, Neural Machine Translation by Jointly
95
Attention Mechanism Simple Attention Networks untuk Sentence Classification 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
96 Colin Raffel, Daniel P. W. Ellis, F EED -F ORWARD NETWORKS WITH ATTENTION CAN
Attention Mechanism Hierarchical Attention Networks untuk Sentence Classification 7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
97 Yang, Zichao, et al., Hierarchical Attention Networks for Document Classification, NAACL 2016
Attention Mechanism Hierarchical Attention Networks untuk Sentence Classification Task: Prediksi Rating Dokumen
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
98 Yang, Zichao, et al., Hierarchical Attention Networks for Document Classification, NAACL 2016
Attention Mechanism
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
99 https://blog.heuritech.com/2016/01/20/attention-mechanism/
Attention Mechanism
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
100 https://blog.heuritech.com/2016/01/20/attention-mechanism/ Xu, Kelvin, et al. « Show, Attend and Tell: Neural Image Caption
Attention Mechanism
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
101 https://blog.heuritech.com/2016/01/20/attention-mechanism/ Xu, Kelvin, et al. « Show, Attend and Tell: Neural Image Caption
Attention Mechanism Attention Mechanism untuk Textual Entailment Diberikan pasangan premis-hipotesis, tentukan apakah 2 tersebut kontradiksi, tidak berhubungan, atau logically entail. Sebagai contoh: •
Premis: “ A wedding party taking pictures“
•
Hipotesis: “Someone got married “
Attention Model digunkan untuk menghubungkan kata-kata di premis dan hipotesis.
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
102
Attention Mechanism Attention Mechanism untuk Textual Entailment Dibe Diberi rika kan n pasa pasang ngan an prem premis is-h -hip ipot otes esis is,, tent tentuk ukan an apak apakah ah 2 ters terseb ebut ut kontradiksi, kontradiksi, tidak tidak berhubu berhubung ngan an,, atau logica logicall lly y entail entail..
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
103
Recur Re cursi siv ve Neu Neura rall Net Netw wor orks ks
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
104 R. Socher, Socher, C. Lin, A. Y. Y. Ng, and C.D. Manning. 2011a. Parsing Natural Scenes and Natural Language with
Recur Re cursi siv ve Neu Neura rall Net Netw wor orks ks
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
p1
g W . b; c bias
Socher et al., Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank, Treebank, EMNLP
105
Recursive Neural Networks
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
106 Socher et al., Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank, EMNLP
Convolutional Neural Networks (CNNs) for Sentence Classification
(Kim, EMNLP 2014)
7 1 0 2 r e b o t c O 9 I U M O K L I S A F , o n o s k a c i W . F n a f l A
107