Relative Content

Tag Archive for pythoncmdfloating

weird error——ZeroDivisionError: float division by zero but it’s not zero

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/metrics/bleu.py in accumulate(self) 230 logs = math.fsum(w_i * math.log(p_i) 231 for w_i, p_i in zip(self.weights, prob_list)) –> 232 if float(self.bp_c) != 0: 233 bp = math.exp(min(1 – self.bp_r / float(self.bp_c), 0)) 234 else: ZeroDivisionError: float division by zero This error always raises even though I added if/else to prevent the situation that float(self.bp_c) is zero, […]