RuntimeWarning: invalid value encountered in multiply
I have a code:
a = Y_list * np.log(Y_list/E_Y) print(a) My Y_list contains 0 values, I'm wondering how to do when Y_list = 0 , np.log(0) = 0?
RuntimeWarning: invalid value encountered in multiply
I have a code:
a = Y_list * np.log(Y_list/E_Y) print(a) My Y_list contains 0 values, I'm wondering how to do when Y_list = 0 , np.log(0) = 0?
You can use np.where It lets you define a condition for true and false and assign different values.
np.where((Y_list/E_Y)!= 0, np.log(Y_list/E_Y),0)