numpy.log10(prob)
calculates the base 10 logarithm for all elements of prob
, even the ones that aren't selected by the where
. If you want, you can fill the zeros of prob
with 10**-10
or some dummy value before taking the logarithm to get rid of the problem. (Make sure you don't compute prob > 0.0000000001
with dummy values, though.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…