My Math Notes
  • Home
  • Calculus Notebooks
    • Backpropagation
    • Optimizing Functions of One Variable: Cost Minimization
    • Differentiation in Python: Symbolic, Numerical and Automatic
    • Optimization Using Gradient Descent: Linear Regression
    • Optimization Using Gradient Descent in One Variable
    • Optimization Using Gradient Descent in Two Variables
    • Neural Network with Two Layers
    • Regression with Perceptron
    • Classification with Perceptron
    • Optimization Using Newton's Method
    • Fitting the distribution of heights data
    • Gradient descent in a sandpit
    • The Sandpit - Part 2
    • The Sandpit
  • Deeplearning.ai
    • Calculus
    • Linear Algebra
    • Probability and Statistics
  • Imperial College
    • Linear Algebra
    • Multivariate Calculus
    • PCA
  • Linear Algebra Notebooks
    • Single Perceptron Neural Networks for Linear Regression
    • Single Perceptron Neural Networks for Linear Regression
    • Eigenvalues and Eigenvectors
    • Gram-Schmidt process
    • Identifying special matrices
    • PageRank
    • Reflecting Bear
    • Linear Transformations
    • Matrix Multiplication
    • Solving Linear Systems: 2 variables
    • Vector Operations: Scalar Multiplication, Sum and Dot Product of Vectors
  • PCA notebooks
    • Distances and Angles between Images
    • K nearest Neighbors Algorithm
    • Week 1: Mean/Covariance of a data set and effect of a linear transformation
    • Orthogonal Projections
    • Principal Component Analysis (PCA)
    • Demonstration of PCA
  • Previous
  • Next
  • The Sandpit - Part 2
    • Multiple Minima
    • Noisy Functions
    • Narrow Wells

The Sandpit - Part 2¶

In this notebook, we'll explore some more sandpit scenarios in order to build on your intuition of the Jacobian and gradient descent. We'll look at some harder scenarios and some of the pitfalls and limitations of following the gradient down contours in order to find the minimum of a function.

There is no grading for this exercise, when you are finished, close this tab to return to the course.

Multiple Minima¶

In this sandpit, there are many local minima that the supervisor's phone could have fallen into. The phone is in the deepest one - Try and find it!

(You may get lucky and find the basin of the deepest minimum quickly, if you seem stuck, click somewhere else at random!)

In [4]:
Copied!
# Click into this cell and press [Shift-Enter] to start.
%run "readonly/sandpit-exercises.ipynb"
sandpit_multiple_minima()
# Click into this cell and press [Shift-Enter] to start. %run "readonly/sandpit-exercises.ipynb" sandpit_multiple_minima()
/opt/conda/lib/python3.6/site-packages/IPython/core/magics/pylab.py:160: UserWarning: pylab import has clobbered these variables: ['imread']
`%matplotlib` prevents importing * from pylab and numpy
  "\n`%matplotlib` prevents importing * from pylab and numpy"
No description has been provided for this image
A Jupyter Widget

Noisy Functions¶

Before the sand was loaded into this next pit, the pit floor was covered with rocks. This means when the supervisor tries to measure the slope, the surface they measure is rough and can change quickly.

Try to find the phone in this situation. You may notice that it is frustratingly harder to do so, as the roughness may generate more local minima.

In [5]:
Copied!
# Click into this cell and press [Shift-Enter] to continue.
%run "readonly/sandpit-exercises.ipynb"
sandpit_rocks()
# Click into this cell and press [Shift-Enter] to continue. %run "readonly/sandpit-exercises.ipynb" sandpit_rocks()
/opt/conda/lib/python3.6/site-packages/IPython/core/magics/pylab.py:160: UserWarning: pylab import has clobbered these variables: ['imread']
`%matplotlib` prevents importing * from pylab and numpy
  "\n`%matplotlib` prevents importing * from pylab and numpy"
No description has been provided for this image
A Jupyter Widget

Narrow Wells¶

In this pit, there is a deep but narrow well that the phone may have fallen into. See if you can find the phone in this case.

In [6]:
Copied!
# Click into this cell and press [Shift-Enter] to continue.
%run "readonly/sandpit-exercises.ipynb"
sandpit_well()
# Click into this cell and press [Shift-Enter] to continue. %run "readonly/sandpit-exercises.ipynb" sandpit_well()
/opt/conda/lib/python3.6/site-packages/IPython/core/magics/pylab.py:160: UserWarning: pylab import has clobbered these variables: ['imread']
`%matplotlib` prevents importing * from pylab and numpy
  "\n`%matplotlib` prevents importing * from pylab and numpy"
No description has been provided for this image
A Jupyter Widget
In [ ]:
Copied!


Documentation built with MkDocs.

Keyboard Shortcuts

Keys Action
? Open this help
n Next page
p Previous page
s Search