Zum Inhalt springen

Datei:Gradient descent.gif

Aus MOOCsWiki Staging
Gradient_descent.gif (360 × 292 Pixel, Dateigröße: 1,51 MB, MIME-Typ: image/gif, Endlosschleife, 50 Bilder)

Diese Datei stammt aus Wikimedia Commons und kann von anderen Projekten verwendet werden. Die Beschreibung von deren Dateibeschreibungsseite wird unten angezeigt.

Beschreibung

Beschreibung
English: Gradient descent is a simple method to find the minimum of a function, where at each iteration a small step is made in the direction of the steepest descent. It tends to get stuck in a local minimum, so it is often run with several initial conditions.
Datum
Quelle https://twitter.com/j_bertolotti/status/1121054414066810881
Urheber Jacopo Bertolotti
Genehmigung
(Weiternutzung dieser Datei)
https://twitter.com/j_bertolotti/status/1030470604418428929

Mathematica 11.0 code

f = Evaluate[x^2 + y^2 + Total@Table[RandomReal[{0,2}] E^(-(((x - RandomReal[{-1, 1}])^2 + (y + RandomReal[{-1, 1}])^2)/(2 RandomReal[{0.1, 0.4}]^2))), {10}]];

step = 0.02;
nstep = 100;
coord = {-1, 1};
pos = {coord[[1]], coord[[2]], f /. {x -> coord[[1]], y -> coord[[2]]}};
evo = Reap[Do[
      subst = MapThread[Rule, {{x, y, z}, pos}];
      dfx = (D[{x, y, f}, x] /. subst);
      dfy = (D[{x, y, f}, y] /. subst);
      tmp = {D[f, x] /. subst, D[f, y] /. subst};
      pos = pos - step {tmp[[1]], tmp[[2]], 0};
      pos[[3]] = Evaluate[f /. {x -> pos[[1]], y -> pos[[2]]}];
      Sow[pos];
      , nstep];][[2, 1]];

coord = {-1, -1};
pos = {coord[[1]], coord[[2]], f /. {x -> coord[[1]], y -> coord[[2]]}};
evo1 = Reap[Do[
      subst = MapThread[Rule, {{x, y, z}, pos}];
      dfx = (D[{x, y, f}, x] /. subst);
      dfy = (D[{x, y, f}, y] /. subst);
      tmp = {D[f, x] /. subst, D[f, y] /. subst};
      pos = pos - step {tmp[[1]], tmp[[2]], 0};
      pos[[3]] = Evaluate[f /. {x -> pos[[1]], y -> pos[[2]]}];
      Sow[pos];
      , nstep];][[2, 1]];

coord = {1, 1};
pos = {coord[[1]], coord[[2]], f /. {x -> coord[[1]], y -> coord[[2]]}};
evo2 = Reap[Do[
      subst = MapThread[Rule, {{x, y, z}, pos}];
      dfx = (D[{x, y, f}, x] /. subst);
      dfy = (D[{x, y, f}, y] /. subst);
      tmp = {D[f, x] /. subst, D[f, y] /. subst};
      pos = pos - step {tmp[[1]], tmp[[2]], 0};
      pos[[3]] = Evaluate[f /. {x -> pos[[1]], y -> pos[[2]]}];
      Sow[pos];
      , nstep];][[2, 1]];

p1 = Table[
   Show[
    Plot3D[f, {x, -1.35, 1.35}, {y, -1.35, 1.35}, Boxed -> False, Axes -> False(*,PlotStyle\[Rule]{Opacity[0.3]}*)],
    Graphics3D[{PointSize[0.03], Point[evo[[j]] ], Thick, Line[evo[[1 ;; j]] ], Point[evo1[[j]] ], Line[evo1[[1 ;; j]]] , Point[evo2[[j]] ], Line[evo2[[1 ;; j]]] }]
    ]
   , {j, 1, nstep, 2}];
ListAnimate[p1]

Lizenz

Ich, der Urheber dieses Werkes, veröffentliche es unter der folgenden Lizenz:
Creative Commons CC-Zero Diese Datei wird unter der Creative-Commons-Lizenz CC0 1.0 Verzicht auf das Copyright zur Verfügung gestellt.
Die Person, die das Werk mit diesem Dokument verbunden hat, übergibt dieses weltweit der Gemeinfreiheit, indem sie alle Urheberrechte und damit verbundenen weiteren Rechte – im Rahmen der jeweils geltenden gesetzlichen Bestimmungen – aufgibt. Das Werk kann – selbst für kommerzielle Zwecke – kopiert, modifiziert und weiterverteilt werden, ohne hierfür um Erlaubnis bitten zu müssen.

Kurzbeschreibungen

Ergänze eine einzeilige Erklärung, was diese Datei darstellt.
Gradient descent with 3 different initial conditions.

In dieser Datei abgebildete Objekte

Motiv

Einige Werte ohne einen Wikidata-Eintrag

image/gif

1.586.553 Byte

292 Pixel

360 Pixel

5f21ecb37864995659c598e1bd301e90e17ae8b1

Dateiversionen

Klicke auf einen Zeitpunkt, um diese Version zu laden.

Version vomVorschaubildMaßeBenutzerKommentar
aktuell10:43, 25. Apr. 2019Kein Vorschaubild vorhanden360 × 292 (1,51 MB)wikimediacommons>BertoUser created page with UploadWizard

Die folgenden 2 Seiten verwenden diese Datei:

Metadaten