ANN Tutorial 語音訊號處理之初步實驗 NTU Speech Lab 指導教授: 李琳山 助教: 熊信寬 ㄊ ㄞ ㄨ ㄢ ㄉ ㄒ ㄚ ㄩ ㄝ Acoustic Model 台 灣 大 Language Model 學 Speech Recognition Classifier ㄅㄆㄇㄈ ㄉㄊㄋㄌ ㄍㄎㄏ ㄐㄑㄒ ㄓㄔㄕㄖ ㄗㄘㄙ ㄧㄨㄩ ㄚㄛㄜㄝ ㄞㄟㄠㄡ ㄢㄣㄤㄥ ㄦ How do we build this machine? Our Task • “Field of study that gives computers the ability to learn without being explicitly programmed” • Instead of writing a program by hand for each specific task, we collect lots of examples that specify the correct output for a given input. • A machine learning algorithm then takes these examples and produces a program that does the job. • The program produced by the learning algorithm may look very different from a typical hand-written program. It may contain millions of numbers. • If we do it right, the program works for new cases as well as the ones we trained it on. • If the data changes the program can change too by training on the new data. • Massive amounts of computation are now cheaper than paying someone to write a task-specific program. Machine Learning Reference: Neural Networks for Machine Learning course by Geoffrey Hinton, Coursera Features •Hair Length •Make-up . . . Classifier Classes Male Classifier Female Others The Classification Task Female Male Make-Up Hair Length Voice pitch 2D Feature Space • We need some type of non-linear function! Multi-D Feature Space • Each neuron receives inputs from other neurons • The effect of each input line on the neuron is controlled by a synaptic weight • The weights can be positive or negative. • The synaptic weights adapt so that the whole network learns to perform useful computations • Recognizing objects, understanding language, making plans, controlling the body. Neurons Reference: Neural Networks for Machine Learning course by Geoffrey Hinton, Coursera Feed Forward Net activation function x1 x2 x3 w1 w2 w3 i th input bias y f (b xi wi ) output y i index over input connections weight on i th w4 b x4 1 • A lot of simple non-linearity complex non-linearity Artificial Neural Network input • Sigmoid Function A.K.A Logistic Function Activation Function • Intuition: 1. Start with random weights 2. Compare the outputs of the net to the targets 3. Try to adjust the weights to match the outputs with the targets E E w 1 2 (t joutput j yj tj Target 0.2 0 0.9 1 1 4 -3 w y j )2 How Do Neural Nets Learn? x1 x2 w1 w2 x3 w3 x4 w4 Error w 2 w 1 wt 1 wt E w Updated weights Learning rate Gradient Descent Reference: Machine Learning course by Andrew Ng, Coursera E dy j E E y j (1 y j ) z j dz j y j y j j zj i yi E 1 2 (t joutput j y j )2 yj ¶E = ¶yi dz j ¶E å dy ¶z = i j j å wij j ¶z j ¶E ¶E ¶E = = yi ¶wij ¶wij ¶z j ¶z j E yout (t yout ) Back Propagation Reference: Neural Networks for Machine Learning course by Geoffrey Hinton, Coursera ¶E ¶z j output = y input = x • Which model do you trust? • The complicated model fits the data better. • But it is not economical. • A model is convincing when it fits a lot of data surprisingly well. • Not just the training data. Which output value should you predict for this test input? Overfitting Reference: Neural Networks for Machine Learning course by Geoffrey Hinton, Coursera • Divide dataset into training set and validation set • Use training set for training, validation set as indicator to overfitting • Use another independent testing test to performance Training and Testing ㄊ ㄞ ㄨ ㄢ ㄉ ㄒ ㄚ ㄩ ㄝ Acoustic Model 台 灣 大 Language Model 學 Speech Recognition ㄅㄆㄇㄈ ㄉㄊㄋㄌ ㄍㄎㄏ ㄐㄑㄒ ㄓㄔㄕㄖ ㄗㄘㄙ ㄧㄨㄩ ㄚㄛㄜㄝ ㄞㄟㄠㄡ ㄢㄣㄤㄥ ㄦ Our Task MFCC:13 Dim Vector We can ‘splice’ the right and left 4 MFCCs to form a 13 x 9 = 117 Dim Vector Example --- Inputs • Right context dependent initial final phones • ‘a’, ‘ai’, ‘an’, ‘ang’, ‘au’, ‘b_a’, ‘b_e’, ‘b_ee’, ‘b_i’ … 117 Dim MFCC Example --- Output Target ‘a’ 0 ‘ai’ 1 ‘an’ 0 • net = newff(Feature,Label,10); % given Feature and Label, this command generates an NN with 10 hidden units • net = newff(Feature,Label,[20 10],{'logsig' 'tansig'}); % this command generates an NN with two layers, one with 20 units and sigmoid as activation function, one with 10 units and tanh as activation function Matlab NN toolkit---Net • [net,tr] = train(net,Feature,Label); % this command will train the network, dividing your dataset into training, validation, and testing set Matlab NN Toolkit ---Train • out = sim(net,testInputs); • % this command runs the command you have trained on a test data set to obtain outputs Matlab NN Toolkit ---Test • nntool % this command calls a GUI for NN visualization Matlab NN Toolkit ---NNTool • Location: http://140.112.21.15/~poetek/NNkit/ • Copy the folder to your computer, and run the file ‘run.m’ for a quick demo Demo Program DEMO • Example (1): Classify the inputs into 4 classes: {‘a’, ‘e’, ‘i’, ‘u’} ans = correct: 1139 out of 1205 accuracy = 0.9452 classification = 214 3 0 3 13 195 9 6 0 5 377 12 1 11 3 353 Demo Program --- Results • Example (2): Classify the inputs into 6 classes: {‘a’, ‘e’, ‘i’, ‘u’, ‘b_a’, ‘p_a’, ‘m_a’, ‘f_a’} correct: 1293 out of 1446 accuracy = 0.8942 classification = 207 7 0 5 204 8 2 9 397 2 10 2 3 1 1 0 0 0 2 5 2 8 5 2 0 0 16 1 8 0 348 0 1 63 2 5 6 4 5 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 14 4 0 74 Demo Program --- Results(2) • Example (3): Classify the inputs into all 147 classes correct: 92 out of 506 accuracy = 0.1818 Demo Program --- Results(3) • Please run example 1~3 with the demo program, record your performance, run time and your observations • Please play around with different settings to achieve better accuracy Some parameters you can change: • Net structure • Training algorithm • Input Features • net.trainParam (Please type ‘help newff’ for more info) Assignments • Neural Networks for Machine Learning course by Geoffrey Hinton, Coursera • Machine Learning course by Andrew Ng, Coursera • Matlab NN toolkit documentation References • Feel free to ask questions! My Email: b98901024@ntu.edu.tw Thank You!