RuntimeWarning: invalid value encountered in true_divide
Add the following before this line:
numpy.seterr(divide='ignore', invalid='ignore')
或者是:RuntimeWarning: invalid value encountered in divide
import numpy as np
olderr = np.seterr(all='ignore')
==========================
You may have a NAN, INF, or NINF floating around somewhere. Try this:
np.isfinite(diff_images).all()
np.isfinite(b_0).all()
If one or both of those returns False, that's likely the cause of the runtime error.
==================
解决:
这样:
python -W ignore::RuntimeWarning my_script.py
或者这样:
import warnings
warnings.filterwarnings("ignore")