49
Yapay Sinir Ağları YZM 3226 – Makine Öğrenmesi

Yapay Sinir Ağları - Algoritma ve Programlama Bilgi ... · 10/5/2016  · Yapay Sinir Ağları İnsan beyninin özelliklerinden olan öğrenme, yeni bilgiler türetme ve keşfedebilme

  • Upload
    others

  • View
    23

  • Download
    1

Embed Size (px)

Citation preview

Yapay Sinir Ağları

YZM 3226 – Makine Öğrenmesi

Paradigms of Machine Learning

Rule Induction

Machine

Learning

Neural Network

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 Unsupervised Learning

Classification

Regression

Clustering - SOM

Association AnalysisDecision Tree Learning

Bayesian Learning

Nearest Neighbour

Neural Networks

Support Vector Machines

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 neuronreceives 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 ~ 104-5

Neurons in the Brain

◘ İnsan beyininde 1012 nöron ve 1014 sinaptic bağlantı olduğu tahmin

edilmektedir.

synapses

axondendrites

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 SinirAğları

Dendrit Girdi Xh

Sinaps Ağırlık Wh

Nucleus Toplama Fonksiyonu Σ

Cell Body (Soma) Transfer Fonksiyonu f

Axon Çıktı y

14

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.

One layer of neural

units

Another layer of

neural units

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

◘ 200 billion neurons, 32 trillion

synapses

◘ Analog

◘ Paralel

◘ Bilgiye adapte olma

◘ Birimlerin ana işlemlere etkisi azdır.

◘ Giriş verilerindeli hatalara her zaman

duyarlı değildir.

◘ 1 billion bytes RAM but trillions of bytes

on disk

◘ Sayısal

◘ Seri

◘ Komut kümeli

◘ Yanlış hesaplamalar sonucu etkiler.

◘ Giriş verilerindeki hatalar sonucu etkiler.

Beyin vs Bilgisayar

◘ 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.

Why Neural Network?

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

Salary

#mouth

Debt

good

medium

bad

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

Unit Step Sigmoid

Piecewise Linear

Gaussian

Identity

f (x) = x

Hiberbolik Tanjant

f(s) = (1 – exp(-2s))/ (1 +exp(-2s))

Activation Functions

Activation Function Example

Input Output

3 1 0 -2 1

0 10 0 0 0

… …

Training Data Unit Step

0.3

-0.1

2.1

-1.1

3

1

0

-2

0.3

-0.1

2.1

-1.1

3

1

0

-2

3

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

f (3) 1

0.3

-0.1

2.1

-1.1

0

10

0

0

-1

f (1) 0

Activation Function Example

Input Output

3 1 0 -2 1

0 10 0 0 0

… …

Training Data

0.3

-0.1

2.1

-1.1

3

1

0

-2

0.3

-0.1

2.1

-1.1

3

1

0

-2

3

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

SigmoidΒ=2

f (x) 1

1 e2x

f (3) 1

1 e2x .998

36

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

0.400078Sum squared error =

Sum Squared Error Example

2

1

)( s

mplesnumTrainSa

s

s putDesiredOututActualOutp

38

Single layer

Multiple layer

fully connected

Recurrent network

without hidden units

inputs

outputs

Recurrent network

with hidden units

Unit delay

operator

Network Architecture

◘ Hebb Net

◘ Perceptron

◘ Hopfield

◘ Kohonen - Self Organizing Feature Map(SOM)

◘ Backpropagation Net

Temel YSA Modelleri

Artificial Neural Networks

Feedforward Recurrent

Kohonen, Hebbian MLP, RBF

Unsupervised Supervised

ART Hopfield

Unsupervised Supervised

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 functionx1 x2 t x1 x2 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

AND OR

Perceptron

◘ Perceptrons can only perform accurately with

linearly separable classes

◘ Able to solve non-linear classification

problems

◘ Solution: additional (hidden) layers of neurons,

MLP architecture

x1

x2

x1

x2

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

I1

I2

I3

I4

I5

I6

a1 = O1

a2 = O2

Inputs ak=Ik

Hidden Units

Output Units

Weights on links

from input to hidden

Wk,j

Weights on links

from hidden to output

Wj,iAj

Network Activations

Ai

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 layer

Input layer

Hidden layer

Output vector

Input vector: X

wij

i

jiijj OwI

jIje

O

1

1

))(1( jjjjj OTOOErr

ijijij OErrlww )(

jjj Errl)(

A more typical NN

Classification by Back Propagation

◘ Data Mining : Classification by Back Propagation Neural Network

Classification by Back Propagation

1

0

1

1

0

10.33

0.525

10.33

0.525

1

0

jkk

kjjj wErrOOErr )1(

1

0

1-0.2

0.4

-0.5

-0.7

i

jiijj OwI

1

0

1-0.2

0.4

-0.5

-0.7 0.33

jIje

O

1

1

Update the weights and bias values

0.474

Correct Output: 0.6

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 number of

iterations

Hata

Iterationt

Hata

Iteration

ε

According to the error value

Overfitting

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.

Error

Iteration

Training

Testing

Stop here