Yapay Sinir Ağları YZM 3226 Makine Öğrenmesi
Outline Yapay Sinir Ağları Tanımı Tarihçe Neden YSA kullanırız? YSA uygulamaları Temel YSA modelleri
Paradigms of Machine Learning Rule Induction Neural Network Machine Learning Genetic Algorithms Decision Trees Bayessian Learning YSA(Neural Network) makine öğrenmesine ait alt dallardan biridir.
Learning with Neural Network YSA ile öğrenme Gözetimli(superviser) Gözetimsiz(unsupervised) olabilir.
Learning Types Learning Supervised Learning Classification Unsupervised Learning Clustering - SOM Decision Tree Learning Bayesian Learning Nearest Neighbour Neural Networks Support Vector Machines Regression Association Analysis Sequence Analysis Summerization Descriptive Statistics Outlier Analysis Scoring
From Biological to Artificial System (1)
From Biological to Artificial System (3)
Neurons in the Brain Bir nöron diğer bir nörondan sinapsler aracılığı ile bilgi alır.a neuron receives input from other neurons (generally thousands) from its synapses Inputs are approximately summed When the input exceeds a threshold the neuron sends an electrical spike that travels from the body, down the axon, to the next neuron(s)
Human Brain İnsan beyini içerisinde 50-100 bilyon civarında sinir hücresi olduğu tahmin edilmektedir. Bir sinir hücresi Soma/Çekirdek Dendrit Akson Sinaps/Bağlantılar Kimyasal sinapslar aksonları kullanarak, neronların dendritleri arasında iletişim sağlar. Connections per neuron ~ 10 4-5
Neurons in the Brain İnsan beyininde 10 12 nöron ve 10 14 sinaptic bağlantı olduğu tahmin edilmektedir. axon dendrites synapses
Yapay Sinir Ağları İnsan beyninin özelliklerinden olan öğrenme, yeni bilgiler türetme ve keşfedebilme gibi yetenekleri herhangi bir yardım almadan otonom olarak gerçekleştirmek amacı ile geliştirilen bilgisayar sistemleridir. Dışarıdan aldığı dinamik verilere göre dinamik sonuçlar üreten birbirine bağlı basit elemanlardan oluşan bir yapıdır.
Neural Network Biyolojik Nöron Yapay Sinir Ağları Dendrit Girdi X h Sinaps Ağırlık W h Nucleus Toplama Fonksiyonu Σ Cell Body (Soma) Transfer Fonksiyonu f Axon Çıktı y
Graphical Notation & Terms Daireler Sinir hücresi birimlerini temsil eder. Oklar Bir birimden diğerine sinaptik bağlantıları gösterir. Bunlar ağırlık olarak adlandırılır ve numerik değerler ile gösterilebilir. Another layer of neural units One layer of neural units 14
Mathematical Representation Bir nöron kendisine dışarıdan gelen inputların ağırlığını toplar ve olması gereken eşik değer(threshold) ile kıyaslar. For example: If the sum is higher than the threshold, the output is set to 1, otherwise to -1. Non-linearity
Beyin vs Bilgisayar 200 billion neurons, 32 trillion synapses 1 billion bytes RAM but trillions of bytes on disk Analog Sayısal Paralel Seri Bilgiye adapte olma Komut kümeli Birimlerin ana işlemlere etkisi azdır. Yanlış hesaplamalar sonucu etkiler. Giriş verilerindeli hatalara her zaman duyarlı değildir. Giriş verilerindeki hatalar sonucu etkiler.
Why Neural Network? YSA avantajları: Komplex problemlerde dahi başarılıdır. Problemleri paralel bir şekilde ele alıp çözebilir. YSA dezavantajları: Complexity arttıkça performans azalır. Elimizde büyük bir veri seti varsa execution time artar.
Applications Pattern Recognition (Image / Speech) (text, numbers, faces) Data Mining Classification Classification of galaxies Diagnosing medical conditions Prediction Forecast of energy consumption Stock value forecast Outlier Detection Fraud detection - Monitoring of credit card accounts Automation and Control process, robotics
Applications Marketting Product orders (Supermarket) Predicting time-series in financial world Identifying valuable customers... Medical Analysis of electrocardiogram data, RNA & DNA sequencing, Drug development without animal testing Telecommunication Manufacturing quality control, fault diagnosis Signal Processing
Applications Banking Credit application evaluators Automotive Automobile automatic guidance systems Financial Real estate appraisal, loan advisor, mortgage screening, corporate bond rating, credit line use analysis, portfolio trading program, corporate financial analysis, currency price prediction Transportation Vehicle scheduling, routing Data Filtering e.g. take the noise out of a telephone signal, signal smoothing
Example NN Job(1/0) age good Salary medium #mouth bad Debt Input layer Hidden layer Output layer
NN Example - Real Estate Appraiser A Neural Network is like a black box that knows how to process inputs to create a useful output. The calculation(s) are quite complex and difficult to understand Loan Prospector
Autonomous Land Vehicle In a Neural Network (ALVINN) ALVINN is an automatic steering system for a car based on input from a camera mounted on the vehicle.
ALVINN The ALVINN neural network is shown here. It has 960 inputs (a 30x32 array derived from the pixels of an image), four hidden units and 30 output units (the output is the direction in which the vehicle is steered)
ALVINN
Model of a Neuron
Activation Functions Unit Step Sigmoid Gaussian Piecewise Linear Identity Hiberbolik Tanjant f (x) = x f(s) = (1 exp(-2s))/ (1 +exp(-2s))
Activation Function Example Training Data Input Output 3 1 0-2 1 0 10 0 0 0 Unit Step 3 0.3 3 0.3 0 0.3 1 0-0.1 2.1 1 0-0.1 2.1 3 f (3) 1 10 0-0.1 2.1-1 -2-1.1-1.1-2 Input: (3, 1, 0, -2) 0-1.1 f ( 1) 0 Processing: 3(0.3) + 1(-0.1) + 0(2.1) + -1.1(-2) = 0.9 + (-0.1) + 2.2 Output: 3
Activation Function Example Training Data Input Output 3 1 0-2 1 0 10 0 0 0 Sigmoid Β=2 f (x) 1 1 e 2x 3 0.3 3 0.3 1 0-0.1 2.1 1 0-0.1 2.1 3 f (3) 1.998 2x 1 e -2-1.1-1.1-2 Input: (3, 1, 0, -2) Processing: 3(0.3) + 1(-0.1) + 0(2.1) + -1.1(-2) = 0.9 + (-0.1) + 2.2 Output: 3
Sum Squared Error Example Expected Actual x1 x2 z1 z1 squared error 0 0 1 0.925 0.005625 0 1 0 0.192 0.036864 1 0 0 0.19 0.0361 1 1 1 0.433 0.321489 Sum squared error = 0.400078 numtrainsamples ( ActualOutp uts DesiredOut puts s 1 ) 2 36
Network Architecture Single layer Multiple layer fully connected Unit delay operator outputs Recurrent network without hidden units inputs Recurrent network with hidden units
Temel YSA Modelleri Hebb Net Perceptron Hopfield Kohonen - Self Organizing Feature Map(SOM) Backpropagation Net Artificial Neural Networks Feedforward Recurrent Unsupervised Supervised Kohonen, Hebbian MLP, RBF Unsupervised ART Supervised Hopfield
Hebb Net Yapay sinir agi modellerinin ilk bilinen tipidir. Ögrenme metodolojisinde Hebb kuralini kullandigi için bu adi almistir. Eger iki hücre ayni aktivasyonu gösteriyorsa arasindaki bagin kuvvetlenmesi gerekir. Eger ikisinin aktivasyonu farkli ise aralarindaki bag degismez ya da azaltilmalidir. Yapı itibariyle ileri beslemeli olan bu model, tek katmanli bir yapi ile olusturulmustur. Bu yapi girdi hücreleri ve onlarin bagli oldugu çikti hücresinden ibarettir.
Perceptron Hebb net in ögrenme kavrami yerine simdi esikleme fonksiyonundan geçirilme kavrami gelmektedir.
Perceptron Perceptron Structure Able to learn AND / OR logic function AND OR x 1 x 2 t x 1 x 2 t 1 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0
Perceptron Perceptrons can only perform accurately with linearly separable classes x 1 x 2 Able to solve non-linear classification problems Solution: additional (hidden) layers of neurons, MLP architecture x 1 x 2
Multi-Layer Perceptrons Learning procedure is extension of simple perceptron algorithm A neural network with at least 1 hidden layer can represent any function
Layers Yapay sinir ağları üç ana katmandan oluşmaktadır; Giriş Katmanı, Ara (Gizli) Katmanlar ve Çıkış Katmanı. Giriş Katmanı: Girdileri alan nöronların bulunduğu katmandır. Bu katmanda nöronlar üzerinde işlem gerçekleşmez, yalnızca girdiler bir sonraki katmana taşınır. Ara (Gizli) Katman(lar): Ağın temel işlemlerini hesaplayan katmandır. Gizli katmanda bulunan her bir işlem elemanı; giriş sinyalini, giriş katmandaki ağırlıklar ile çarparak toplamını alır daha sonra bu toplamı transfer fonksiyonuna aktararak çıkan sonucu başka bir gizli katmana veya son olarak işlem göreceği çıkış katmanına götürür. Çıkış Katmanı: Gizli katmandan iletilen veriyi ağın kullandığı fonksiyonda işleyerek ara katmandan gelen çıktıları dış ortama veya başka bir sinir ağına ileten nöronları oluşturan katmandır.
Two-Layered Feed-Forward Neural Networks Inputs Hidden Units Output Units a k =I k I 1 W k,j A j W j,i A i Weights on links from input to hidden Weights on links from hidden to output Network Activations I 2 I 3 I 4 I 5 a 1 = O 1 a 2 = O 2 I 6
Hidden Layers How many hidden layers should be used? usually just one hidden layer is used How many hidden units should be in a layer? too few and the concept can't be learn too many: examples just memorized "overfitting", poor generalization Use a tuning set or cross-validation to determine experimentally the number of units that minimizes error.
Back Propagation Backpropagation geribeslemeli bir ögrenme mekanizmasi kullanir. Burada yapay sinir aginin yapisi ileribeslemeli olmasina karsin, hatanin geriye dogru ket vurmasindan kaynaklanan bir ögrenme oldugu için geribesleme söz konusu edilmektedir. Ve bu yapay sinir agi modeli ögretmenli ögrenme stratejisini (supervised learning) kullanmaktadir. Used for data modelling, classification, forecasting, data and image compression and pattern recognition.
Back Propagation Error propagated backwards
Back Propagation For each training tuple, the weights are modified to minimize the mean squared error. Output vector Output layer Hidden layer Input layer Input vector: X A more typical NN Err j O ( 1 O j )( Tj O j ) j I j w ij e I w O j ij j j w w ( l) Err ij O i j (l) Err 1 1 ij i j j O j i
Classification by Back Propagation Data Mining : Classification by Back Propagation Neural Network
Classification by Back Propagation 1 1-0.2-0.7 1-0.2-0.7 0.33 0.4 0.4 0 0-0.5 0-0.5 1 1 1 I j w O i ij i j O j 1 1 e I j 1 0.33 1 0.33 0 0 0.474 1 0.525 1 Err j O (1 O ) j j k 0.525 Err k w jk Correct Output: 0.6 Update the weights and bias values
Network Architecture Perceptron structure Multi-Layer-Perceptron structure Backpropagation Net structure
Be careful!! Selection of Samples Momentum Coefficient Stopping Criteria Overfitting
Selection of Samples İyi seçilmemiş örneklerle yeterince iyi bir tahmin gerçekleştirilememiştir. Daha iyi seçilmiş örnekler fonksiyonun daha iyi tahminlenmesini sağlamıştır.
Stopping Criteria According to the error value Hata ε Iteration Hata According to the number of iterations t Iteration
Overfitting Error Stop here Testing Training Iteration Ağ gereğinden fazla eğitilirse problemi öğrenmek yerine verileri ezberler. Bu da ağın genelleme yapamamasını ve hatalı sonuçlar üretmesine neden olur.