Tensorflow Github源代码中的Softmax交叉熵实现 [英] Softmax Cross Entropy implementation in Tensorflow Github Source Code
问题描述
我正在尝试在python中实现Softmax交叉熵损失.因此,我正在研究GitHub Tensorflow存储库中Softmax交叉熵损失的实现.我试图理解它,但是遇到了三个函数的循环,但是我不明白函数中的哪一行代码正在计算损失?
函数 softmax_cross_entropy_with_logits_v2(labels,logits,axis = -1,name = None)
返回函数 softmax_cross_entropy_with_logits_v2_helper(labels = labels,logits = logits,axis = axis,name = name)
,然后返回 softmax_cross_entropy_with_logits(precise_logits,labels,name = name)
.
现在函数 softmax_cross_entropy_with_logits(precise_logits,标签,名称=名称)
返回函数 softmax_cross_entropy_with_logits_v2(标签,logits,轴= -1,名称=无)
./p>
这使我陷入了功能循环,而没有清楚地知道用于计算Softmax函数的 cost
的代码在哪里.有人能指出在Tensorflow GitHub存储库中实现Softmax交叉熵的代码的地方吗?
我正在引用的GitHub存储库的链接为此处.它包含以上三个函数的定义.
如果 cost
的代码需要很多麻烦而又难以理解的功能,那么您也可以解释一下代码行吗?谢谢.
当您遵循此函数的调用堆栈时,最终会找到 <代码>成本,未使用的backprop = gen_nn_ops.softmax_cross_entropy_with_logits(precision_logits,标签,名称=名称) 只要您看到对 C ++源代码这里. If in case the code for When you follow the call stack for this function, you eventually find this: Whenever you see a reference to a C++ source code can be found here. How 这篇关于Tensorflow Github源代码中的Softmax交叉熵实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! gen _
模块的引用,就意味着它是对C ++代码的自动生成的python包装器-这就是为什么您无法通过简单地查找函数并遵循调用堆栈来查找的原因. gen_nn_ops
的创建方式在here. It contains the definitions of the above three functions.cost
requires lots of functions which is cumbersome to understand, could you explain the lines of code as well? Thanks.cost, unused_backprop = gen_nn_ops.softmax_cross_entropy_with_logits(
precise_logits, labels, name=name)
gen_
module, it means it's an automatically generated python wrapper over the C++ code - that's why you cannot find by simply looking up the function and following call stack.gen_nn_ops
is created is nicely described in this answer.