line_search.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Linesearch Gradient 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. <h3> Wolfe Line Search Example </h3>
  45. <hr>
  46. <p> This graph attempts to show how a Wolfe Line Search works.
  47. The goal here is to move downwards along the gradient so that
  48. the loss is reduced sufficiently (controlled by the c1 parameter)
  49. and also that the slope of the loss is decreased sufficiently (controlled by the
  50. c2 parameter). Making sure the slope decreases sufficiently ensures that
  51. we don't take too many short steps, and is usually the more important parameter
  52. here. </p>
  53. <p>
  54. The goal here isn't to exactly find the best point along the line, but to
  55. cheaply find a good enough point. The black dots represent points that were calculated as part of doing the line
  56. search. Minimizing the total number of samples taken while still converging
  57. quickly is the goal here:</p>
  58. <div id ="linesearch" >
  59. <div style="text-align:center"><div style="display:inline-block;">
  60. <h4>
  61. <div class="btn-group">
  62. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  63. <span class="function_sig">
  64. \(f(x, y) \)
  65. </span>
  66. <span class="caret"></span>
  67. </button>
  68. <ul class="dropdown-menu" role="menu">
  69. <li><a class="function_himmelblau">
  70. \((x^2 + y - 11)^2 + (x+y^2 -7)^2\)
  71. </a></li>
  72. <li><a class="function_flower">
  73. \(x^2 + y^2 + x \sin \left( y \right) + y \sin \left( x \right) \)
  74. </a></li>
  75. <li><a class="function_banana">
  76. \((1-x)^2 + 100 (y - x^2) ^2\)
  77. </a></li>
  78. <li><a class="function_matyas">
  79. \(.26 (x^2 + y^2) + .48 x y \)
  80. </a></li>
  81. </ul>
  82. </div>
  83. <span>\(=\)</span>
  84. <span class="function_label">
  85. \((1-x)^2 + 100 (y - x^2) ^2\)
  86. </span>
  87. </h4>
  88. </div></div>
  89. <div id="vis"></div>
  90. <div class="row">
  91. <form class="form-inline" role="form">
  92. <div class="form-group col-xs-6 col-md-6">
  93. <div style="text-align:center"><div style="display:inline-block;">
  94. <label class="r-only" for="c1">C1
  95. <span id="c1value">= 0.00001</span>
  96. </label>
  97. </div></div>
  98. <div id="c1"></div>
  99. </div>
  100. <div class="form-group col-xs-6 col-md-6">
  101. <div style="text-align:center"><div style="display:inline-block;">
  102. <label class="r-only" for="c2">C2
  103. <span id="c2value">= 0.1</span>
  104. </label>
  105. </div></div>
  106. <div id="c2"></div>
  107. </div>
  108. </form>
  109. </div>
  110. <div style="text-align:center"><div style="display:inline-block;">
  111. <div class="row">
  112. <div class ="iterations"></div>
  113. </div>
  114. </div></div>
  115. </div>
  116. <hr>
  117. <br>
  118. </div>
  119. </div>
  120. </body>
  121. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  122. <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
  123. <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script>
  124. <script src="../build/fmin.js"></script>
  125. <script src="../build/fmin_vis.js"></script>
  126. <script>
  127. var line_search_plot = new fmin_vis.LineSearchContour(d3.select("#linesearch"));
  128. </script>
  129. <script type="text/x-mathjax-config">
  130. MathJax.Hub.Config({
  131. showMathMenu: false,
  132. extensions: ["tex2jax.js"],
  133. jax: ["input/TeX", "output/HTML-CSS"],
  134. tex2jax: {
  135. inlineMath: [ ['$','$'], ["\\(","\\)"] ],
  136. displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
  137. processEscapes: true
  138. },
  139. "HTML-CSS": { availableFonts: ["TeX"] }
  140. });
  141. </script>
  142. <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
  143. </html>