gradient_descent.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Gradient Descent Example</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="description" content="">
  8. <meta name="author" content="Ben Frederickson">
  9. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css"/>
  10. <style>
  11. .ticks {
  12. font: 10px sans-serif;
  13. }
  14. .track,
  15. .track-inset,
  16. .track-overlay {
  17. stroke-linecap: round;
  18. }
  19. .track {
  20. stroke: #000;
  21. stroke-opacity: 0.3;
  22. stroke-width: 10px;
  23. }
  24. .track-inset {
  25. stroke: #ddd;
  26. stroke-width: 8px;
  27. }
  28. .track-overlay {
  29. pointer-events: stroke;
  30. stroke-width: 50px;
  31. cursor: crosshair;
  32. }
  33. .handle {
  34. fill: #fff;
  35. stroke: #000;
  36. stroke-opacity: 0.5;
  37. stroke-width: 1.25px;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div class="container">
  43. <div class = "row"><div class="col-md-6 col-md-offset-3">
  44. <div id ="gd" >
  45. <div style="text-align:center"><div style="display:inline-block;">
  46. <h4>
  47. <div class="btn-group">
  48. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  49. <span class="function_sig">
  50. \(f(x, y) \)
  51. </span>
  52. <span class="caret"></span>
  53. </button>
  54. <ul class="dropdown-menu" role="menu">
  55. <li><a class="function_flower">
  56. \(x^2 + y^2 + x \sin y + y \sin x \)
  57. </a></li>
  58. <li><a class="function_himmelblau">
  59. \((x^2 + y - 11)^2 + (x+y^2 -7)^2\)
  60. </a></li>
  61. <li><a class="function_banana">
  62. \((1-x)^2 + 100 (y - x^2) ^2\)
  63. </a></li>
  64. <li><a class="function_matyas">
  65. \(.26 (x^2 + y^2) + .48 x y \)
  66. </a></li>
  67. </ul>
  68. </div>
  69. <span>\(=\)</span>
  70. <span class="function_label">
  71. \((x^2 + y - 11)^2 + (x+y^2 -7)^2\)
  72. </span>
  73. </h4>
  74. </div></div>
  75. <div id="vis"></div>
  76. <div class="row">
  77. <form class="form-inline" role="form">
  78. <div class="form-group col-xs-12 col-md-12">
  79. <div style="text-align:center"><div style="display:inline-block;">
  80. <label class="r-only" for="learningrate">Learning Rate \(\alpha\)
  81. <span id="learningratevalue">= 0.01</span>
  82. </label>
  83. </div></div>
  84. <div id="learningrate"></div>
  85. </div>
  86. </form>
  87. </div>
  88. <div style="text-align:center"><div style="display:inline-block;">
  89. <div class="checkbox">
  90. <label>
  91. <input id="linesearchcheck" type="checkbox"> Use Line Search
  92. </label>
  93. </div>
  94. </div>
  95. <div style="text-align:center"><div style="display:inline-block;">
  96. <div class="row">
  97. <span class ="iterations"></span>
  98. </div>
  99. </div></div>
  100. </div>
  101. </div>
  102. </div>
  103. </body>
  104. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  105. <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
  106. <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script>
  107. <script src="../build/fmin.js"></script>
  108. <script src="../build/fmin_vis.js"></script>
  109. <script>
  110. var gd_plot = new fmin_vis.GradientContour(d3.select("#gd"));
  111. </script>
  112. <script type="text/x-mathjax-config">
  113. MathJax.Hub.Config({
  114. showMathMenu: false,
  115. extensions: ["tex2jax.js"],
  116. jax: ["input/TeX", "output/HTML-CSS"],
  117. tex2jax: {
  118. inlineMath: [ ['$','$'], ["\\(","\\)"] ],
  119. displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
  120. processEscapes: true
  121. },
  122. "HTML-CSS": { availableFonts: ["TeX"] }
  123. });
  124. </script>
  125. <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
  126. </html>