![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Loss function
今天也是要加油的DD
这个作者很懒,什么都没留下…
展开
-
focal loss in keras
from keras import backend as K import tensorflow as tf # import dill def binary_focal_loss(gamma=2., alpha=.25): """ Binary form of focal loss. FL(p_t) = -alpha * (1 - p_t)**gamma * log(p_t) where p = sigmoid(x), p_t = p or 1 - p depe原创 2020-11-26 22:13:28 · 218 阅读 · 1 评论 -
focal loss in pytorch
def multi_label_loss(y_pred, y_true): ''' Zhang, M. L., & Zhou, Z. H. (2006). Multilabel neural networks with applications to functional genomics and text categorization. IEEE transactions on Knowledge and Data Engineering, 18(10), 1338-1351. '''原创 2020-11-26 22:15:56 · 188 阅读 · 0 评论 -
文本生成中的 mask CrossEntropy -Tensorflow
文本生成中的真实标签为 index,shape = [n_batch,] 输出的为概率分布,shape = [n_batch, num_decoder_tokens] 计算 loss 时应 mask 序列 padding部分 Example: sess = tf.Session() y_label_onehot = tf.convert_to_tensor([[1, 0, 0, 0], [0, 0, 1, 0]], dtype=tf.int64) y_label = tf.argmax(y_label_o原创 2020-06-10 15:21:26 · 1102 阅读 · 0 评论