码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-06-13 17:35:40      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:abi   load   like   sts   sum   ike   mic   lis   bsp   

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

标签:abi   load   like   sts   sum   ike   mic   lis   bsp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!