Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

Georg Dorffner / Achim Lewandowski

Ähnliche Präsentationen


Präsentation zum Thema: "Georg Dorffner / Achim Lewandowski"—  Präsentation transkript:

1 Georg Dorffner / Achim Lewandowski
Maschinelles Lernen und Neural Computation Übung: Grundlagen von Matlab und Netlab Georg Dorffner / Achim Lewandowski SS 2008 Maschinelles Lernen und Neural Computation

2 und Neural Computation
Matlab – Nützliches I Zugriff auf die Daten: Per Hand eingeben: >> a=4 %Skalar >> Vektor=[3; 5; 7] >> bmat=[ ; ; ] Aus Ascii-Datei: >> load beispiel.dat Variable (oder Array) heißt nun beispiel Aus Matlab-Datei (Endung .mat): >> load class.mat class.mat kann mehrere Variablen, arrays,… auch mit anderen Namen enthalten SS 2008 Maschinelles Lernen und Neural Computation

3 und Neural Computation
Matlab – Nützliches II Welche Daten sind im Arbeitsspeicher? >> whos Name Size Bytes Class Vektor x double array a x double array bmat x double array Daten abspeichern, alles löschen, neu laden >>save daten Ve* bmat %legt daten.mat an >>clear %loescht alles >>load daten %Vektor und bmat sind wieder geladen SS 2008 Maschinelles Lernen und Neural Computation

4 Matlab – Nützliches III
>>a*bmat %Multiplikation ans = >>c=bmat' %Transponierte c = SS 2008 Maschinelles Lernen und Neural Computation

5 und Neural Computation
Matlab – Nützliches IV >>d=a*bmat d = >>d=a*bmat; %ruhiger Modus ohne Bildschirmausgabe >> help befehl %Hilfe zu befehl >> c=zeros(1,3) ergibt c=[0 0 0] (1x3) >> d=ones(3,1) ergibt d=[1;1;1] (3x1) SS 2008 Maschinelles Lernen und Neural Computation

6 und Neural Computation
Matlab – Nützliches V Matrizen zusammenfügen: >>a=[2 3 4] >>b=[5 6 7] >>c=[a b] c = >>c=[a;b] SS 2008 Maschinelles Lernen und Neural Computation

7 Netlab – Grundsätzliches
netlab.zip, nethelp.zip und foptions.m (ab Matlab 7.0) entpackt und dann in den Pfad aufgenommen: Menupunkt: File – SetPath – Add with Subfolders Verzeichnisse mit Netlab und den Daten aufnehmen Netlab-Befehle stehen nun zur Verfügung Daten werden gefunden SS 2008 Maschinelles Lernen und Neural Computation

8 und Neural Computation
Netlab – GLM glm (General Linear Model) Initialisieren: net=glm(nin,nout,outfunc) Brauche also nin: Dimension der Inputs nout: Dimension der Outputs outfunc: Ausgabefunktion, die eins von den folgenden sein kann: 'linear', 'logistic' oder 'softmax' Brauche (noch) nicht die Daten z.B. net=glm(5,3, 'linear') SS 2008 Maschinelles Lernen und Neural Computation

9 und Neural Computation
Netlab – GLM II net= type: 'glm' nin: 5 nout: 3 nwts: 18 outfn: 'linear' w1: [5x3 double] b1: [ ] SS 2008 Maschinelles Lernen und Neural Computation

10 und Neural Computation
Netlab – GLM III Modell an Daten anpassen: [netneu, options] = netopt(net, options, x, t, alg) net eben definiert options=foptions erzeugt den Optionenvektor (1x18) options(1)=1 %Fehler anzeigen options(14)=30 %Anzahl der Iterationen Daten bestehen aus n Beobachtungen (jeweils Input- und Outputvektor), bspw. n=300 x 300x5-Matrix, t 300x3-Matrix alg= 'scg'‚ (Scaled Conjugate Gradient) netneu=netopt(net, options, x, t, ‚scg') netneu = type: 'glm' nin: 5 nout: 3 nwts: 18 outfn: 'linear' w1: [5x3 double] b1: [ ] SS 2008 Maschinelles Lernen und Neural Computation

11 und Neural Computation
Netlab – GLM IV Outputvektor für neue Daten vorhersagen: tvor = glmfwd(netneu,xneu) netneu eben angepasst bspw. xneu 2x5-Matrix xneu=[ ; ] tvor = SS 2008 Maschinelles Lernen und Neural Computation

12 und Neural Computation
Netlab – MLP I Multilayer-Perceptron: 1. Initialisieren: net=mlp(nin,nhidden,nout,outfunc) z.B. net=mlp(1,4,1, 'linear') type: 'mlp' nin: 1 nhidden: 4 nout: 1 nwts: 13 %number of weights outfn: 'linear' w1: [ ] b1: [ ] w2: [4x1 double] b2: SS 2008 Maschinelles Lernen und Neural Computation

13 und Neural Computation
Netlab – MLP II Multilayer-Perceptron: 2. Trainieren mit x Inputmatrix und t Targetmatrix: bspw. x=5*rand(100,1); t=sin(x)+0.1*rand(100,1); netneu=netopt(net, options, x, t,'scg') 3. Vorhersagen auf Trainingsinput: tfitted=mlpfwd(netneu,x) tfitinitial=mlpfwd(net,x) %ohne Training plot(x,[t tfitted tfitinitial],'.') SS 2008 Maschinelles Lernen und Neural Computation

14 und Neural Computation
Netlab – GMM I Gauss‘sches Mischmodell: 1. Initialisieren: mix = gmm(dim, ncentres,covartype) covartype: 'spherical', 'full', 'diag', z.B. mix=gmm(3,10,'diag') 2. Vortrainieren (k-means) mix2 = gmminit(mix, x,options) 3. Parameter anpassen: mix3=gmmem(mix2, x,options) SS 2008 Maschinelles Lernen und Neural Computation

15 und Neural Computation
Netlab – GMM II Gauss‘sches Mischmodell Beispiel x1=randn(100,1); x2=randn(50,1)*2+4; x3=randn(50,1)*2+12; x=[x1;x2;x3] 1.Initialisieren: mix = gmm(1, 3, 'diag') 2. Vortrainieren (k-means) mix2 = gmminit(mix, x,options) 3. Parameter anpassen: mix3=gmmem(mix2, x,options) SS 2008 Maschinelles Lernen und Neural Computation

16 und Neural Computation
Netlab – GMM III Gauss‘sches Mischmodell Beispiel angepasste Dichte anzeigen lassen: xv=[-2:0.1:15]' yv=gmmprob(mix3,xv) yv2=gmmprob(mix2,xv) plot(xv,[yv yv2]) SS 2008 Maschinelles Lernen und Neural Computation


Herunterladen ppt "Georg Dorffner / Achim Lewandowski"

Ähnliche Präsentationen


Google-Anzeigen