首页 > 其他 > 详细

[Intro to Deep Learning with PyTorch -- L2 -- N20] Cross-Entropy

时间:2020-06-13 17:08:04      阅读:34      评论:0      收藏:0      [点我收藏+]

If I have bunch of events and a bunch of probabilities, how likely is it those events happen based on the probabilities?

If it is very likely then we have a small cross entropy; 

If it is unlikely, then we have a large cross entropy.

技术分享图片

 

 

import numpy as np

# Write a function that takes as input two lists Y, P,
# and returns the float corresponding to their cross-entropy.
def cross_entropy(Y, P):
    Y = np.float_(Y)
    P = np.float_(P)
    return -np.sum(Y * np.log(P) + (1 - Y) * np.log(1 - P))

 

[Intro to Deep Learning with PyTorch -- L2 -- N20] Cross-Entropy

原文:https://www.cnblogs.com/Answer1215/p/13117976.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!