Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b672a3a0
提交
b672a3a0
authored
7月 18, 2012
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #758 from goodfeli/doc
improved doc of tensor.nnet.binary_crossentropy
上级
26ad0835
cd2eb03f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
8 行增加
和
5 行删除
+8
-5
nnet.py
theano/tensor/nnet/nnet.py
+6
-3
test_naacl09.py
theano/tensor/tests/test_naacl09.py
+2
-2
没有找到文件。
theano/tensor/nnet/nnet.py
浏览文件 @
b672a3a0
...
@@ -1410,11 +1410,14 @@ def graph_merge_softmax_with_crossentropy_softmax(node):
...
@@ -1410,11 +1410,14 @@ def graph_merge_softmax_with_crossentropy_softmax(node):
def
binary_crossentropy
(
output
,
target
):
def
binary_crossentropy
(
output
,
target
):
"""
"""
Compute the crossentropy of binary output wrt binary target.
Compute the crossentropy of binary random variables
output and target are each expectations of binary random
variables; target may be exactly 0 or 1 but output must
lie strictly between 0 and 1.
@note: we could use the x log y op to support output=0
@ and output=1. The gradient would still be undefined though.
@note: We do not sum, crossentropy is computed by component.
@note: We do not sum, crossentropy is computed by component.
@todo: Rewrite as a scalar, and then broadcast to tensor.
@todo: Rewrite as a scalar, and then broadcast to tensor.
@todo: This is essentially duplicated as cost.cross_entropy
@warning: OUTPUT and TARGET are reversed in cost.cross_entropy
"""
"""
return
-
(
target
*
tensor
.
log
(
output
)
+
(
1.0
-
target
)
*
tensor
.
log
(
1.0
-
output
))
return
-
(
target
*
tensor
.
log
(
output
)
+
(
1.0
-
target
)
*
tensor
.
log
(
1.0
-
output
))
...
...
theano/tensor/tests/test_naacl09.py
浏览文件 @
b672a3a0
...
@@ -13,8 +13,8 @@ from theano.tests import unittest_tools
...
@@ -13,8 +13,8 @@ from theano.tests import unittest_tools
def
cross_entropy
(
target
,
output
,
axis
=
1
):
def
cross_entropy
(
target
,
output
,
axis
=
1
):
"""
"""
@todo: This is essentially duplicated as
nnet_ops
.binary_crossentropy
@todo: This is essentially duplicated as
tensor.nnet
.binary_crossentropy
@warning: OUTPUT and TARGET are reversed in
nnet_ops
.binary_crossentropy
@warning: OUTPUT and TARGET are reversed in
tensor.nnet
.binary_crossentropy
"""
"""
return
-
T
.
mean
(
target
*
T
.
log
(
output
)
+
(
1
-
target
)
*
T
.
log
(
1
-
output
),
axis
=
axis
)
return
-
T
.
mean
(
target
*
T
.
log
(
output
)
+
(
1
-
target
)
*
T
.
log
(
1
-
output
),
axis
=
axis
)
def
quadratic
(
target
,
output
,
axis
=
1
):
def
quadratic
(
target
,
output
,
axis
=
1
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论