I'm starting out learning about gradient descent, and have a couple of conceptual questions.

1. I noticed a common pitfall of gradient descent is getting stuck in the local optima. How can this be avoided (while still being considered gradient descent)?

2. If a function alternates up and down infinitely across the x axis, does that mean it has an infinite amount of local optima?

Example:

• Comments. Your point (1) is why convex problems tend to be solvable why non-convex problems can be a complete disaster. The answer to (2) is yes. – Matthew Gunn Oct 6 '16 at 0:06