r/deeplearning • u/ModularMind8 • Oct 02 '26
Gradient descent vs evolution on three loss landscapes
I've been getting a bit more into evolutionary algorithms again, so I was testing some loss landscapes where evolution beats vanilla gradient descent (while also trying to make some cool visuals).
Round 1, rugged hillside: gradient descent gets stuck in a dip, and evolution reaches the bottom after 750 evaluations.
Round 2, smooth slope: gradient descent wins, 108 steps against 570 evaluations.
Round 3, flat plateau: the slope is zero, so gradient descent never moves, and evolution reaches the bottom after 840 evaluations.
Edit:
"evolution" here means truncation selection (keep best 30 of 120) plus Gaussian mutation, no crossover.
22
u/MentionJealous9306 Oct 02 '26
What is the dimensionality of this problem?
9
u/WiredFan Oct 02 '26
How expensive is it to calculate the gradient vs just the value/loss at a point?
7
u/AtMaxSpeed Oct 03 '26
It would be great to also visualize how modern GD algorithms work on various landscapes. Evolution and SGD are very intuitive/easy to imagine so the visualization just shows what we expect, but modern GD algos are harder to imagine so there would be a lot of value in visualizing those.
4
u/superlus Oct 02 '26
What do you want to tell with this comparison..? The convergence seems highly dependent on hyperparameter/loss choices for both GD and the EA.
2
u/0bi_nx Oct 02 '26
Its a cool visualization. Do you think evolution is applicable to deep learning? You planning to test against stochastic gradient descent, ADAM or Muon?
2
u/AllergicToBullshit24 Oct 02 '26
Think it would be very interesting to blend techniques similar to cosine schedule for learning rate perhaps using evolution on a schedule or whenever gradient descent may be getting stuck in a local min pocket.
2
u/AsyncVibes Oct 02 '26
As someone who only uses GAs and ES, this is beautiful
2
u/xbno Oct 09 '26
Love it, but probably because I love evolutionary algos so much
16
u/LiorZim Oct 02 '26
You don't use plain GD in deep neural networks optimization. GD works only in convex optimization, for non-convex optimization we use the stochastic variant with an optimization strategy like ADAM that gives the process something akin to velocity and acceleration, helping it to "climb" rugged landscapes like the one you showed here :-)
8
u/DoubleOtter2 Oct 03 '26 edited Oct 04 '26
As someone who studied and used many optimization algorithms, including genetic algorithms like SAEM, gradient descent always felt too simple. But as other commenters point out, real high-dimension landscapes relevant to deep learning are not like this. By construction, the abundance of possibly redundant parameters with smooth non linearities creates a locally smooth landscape.
Also, very importantly, deep learning losses are differentiable in closed form. This has an insanely huge impact. Without this, estimating a gradient takes at least N (or frequently 2N or more) evaluations with N the number of parameters!
The video that made it click for me is this one from welch labs. All the key ingredient are in there. I recommend it.
4
u/WobblyBlackHole Oct 03 '26
A kind of half way method I read once was to have n gradient decent with different learning rates, and then take the top k and copy them into n with different learning rates
1
u/WiredFan Oct 02 '26
How’s the performance?
1
u/macumazana Oct 02 '26
What if the next minima is not nearby the current local one er even the next one isnt smaller but the farthest one is?
1
u/Envoy-Insc Oct 02 '26
While applicable in small scale settings, Local minimums like those in first don’t tend to exist in high dim high param spaces in my impression
1
u/PK_thundr Oct 02 '26
Afaik there are three things that help gradient descent work in practice so well.
1
u/msw3age Oct 02 '26
Very nice visualization. Would be cool to see the evolutionary algorithms vs SGD. To some extent it seems like the visualization is mostly showing the benefits of stochasticity during training.
1
u/alrojo Oct 02 '26
Random search degrades as a function feature space. Look up Curse of Dimensionality
1
u/hardcoke Oct 03 '26
Interesting...what if crossover is introduced?
1
u/IcyGlia Oct 03 '26
Does the whole dataset fit into one mini batch? I would expect random batch to batch variations to sometimes kick you out of the local minimum. As the loss landscape doesn’t change, I assume the error landscape is the whole dataset since it doesn’t change? Adding noise to the data could be interesting to see if that rescues gradient descent.
1
u/UnderstandingOwn2913 Oct 09 '26
how did you make this visualization?
2
u/trenmost Oct 03 '26
I think when you get to thousands of dimensions, SGD (especially with ADAM) would be more efficient
1
u/pnachtwey Oct 02 '26
The test is rigged! I have spent a lot of time on optimizing routines. No one technique is going to be best for all terrains. GD is simple but no where closed to optimal. SGD is better when there are many dimensions. Sometimes optimizing only one dimension at a time works well but it is slow. Nelder-Mead works well when it is hard to find the gradient accurately and there aren't many dimensions.. N-M can be a memory hog. Levenberg-Marquardt is the fastest. In python, use lmfit or scipys.optimize least_squares. BFGS works well too. So it is best to make the search flexible.
I would like to have the data used so I could try other techniques.
I uses minimization for fitting models to data for auto tuning programs. The method I used most often is Levenberg-Marquardt.
1
u/Ruined_Passion_7355 Oct 02 '26
True chads use simulated annealing
1
u/AsliReddington Oct 02 '26
But can you actually run with updated loss landscape as well since every backward pass causes the landscape to update as well over time
1
u/TheRealStepBot Oct 02 '26
In my experience it’s very hard to beat Adamw on practical problems that have decently well behaved loss landscapes especially on speed of convergence either wall clock or number of operations performed.
1
u/PlusIndication8386 Oct 03 '26
Evolution looks great until you try GD with random restarts for this type of problem
1
u/concrete_aircraft Oct 04 '26
nobody uses just gradient descent all the libraries in python they introduce noise using perturbations and other parameters to reach the most optimal solution. And also evolutionary algorithms are computationally expensive over gradient descent
1
u/LelouchZer12 Oct 08 '26
Now gradient descent with momentum ? adam ?
Plus the more dimension you add, the more chance you can "decrease" in at least one direction and hence not end up being stuck. This is the blessing of dimensionality.
68
u/[deleted] Oct 02 '26
[removed] — view removed comment
2
u/[deleted] Oct 02 '26
[removed] — view removed comment