PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 27, 2022

[FIXED] How to hide `delta_grad == 0.0` warning in scipy.optimize.minimize?

 April 27, 2022     python, scipy, scipy-optimize, scipy-optimize-minimize, warnings     No comments   

Issue

I have a loop that executes several hundred optimizations using scipy.optimize.minimize. Unfortunately, I keep getting this annoying warning:

C:\Users\Leonidas\Anaconda3\lib\site-packages\scipy\optimize\_hessian_update_strategy.py:186: UserWarning: delta_grad == 0.0. Check if the approximated function is linear. If the function is linear better results can be obtained by defining the Hessian as zero instead of using quasi-Newton approximations.
  'approximations.', UserWarning)

Because I am running hundreds of optimizations, this warning shows up dozens and dozens of times during the loop, and it just clutters the console and obscures the rest of my program's output. Is there a way to either

  1. Check if this warning has already been displayed, and if so don't display it again, OR
  2. Completely suppress the warning altogether?

Solution

If you want to suppress the specific warning, you can add following at the beginning of your script:

import warnings
warnings.filterwarnings("ignore", message="delta_grad == 0.0. Check if the approximated function is linear.")


Answered By - igrinis
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing