我需要一段计算js散度的python代码

我可以为你提供一段代码:import numpy as npdef js_divergence(p, q): m = 0.5 * (p + q) return 0.5 * (entropy(p, m) + entropy(q, m))def entropy(p, q): return np.sum(np.where(p != 0, p * np.log(p / q), 0))

猜你喜欢

转载自blog.csdn.net/weixin_42601547/article/details/129575363
今日推荐