Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
tensorflow
提交
7aafb97f
T
tensorflow
项目概览
xxadev
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7aafb97f
编写于
12月 09, 2016
作者:
A
A. Unique TensorFlower
提交者:
TensorFlower Gardener
12月 09, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Swaps order of input/label arguments for weighted_cross_entropy_with_logits
Change: 141569831
上级
0cfa416b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
7 deletion
+7
-7
tensorflow/python/ops/nn_impl.py
tensorflow/python/ops/nn_impl.py
+2
-2
tensorflow/python/ops/nn_xent_test.py
tensorflow/python/ops/nn_xent_test.py
+5
-5
未找到文件。
tensorflow/python/ops/nn_impl.py
浏览文件 @
7aafb97f
...
...
@@ -164,7 +164,7 @@ def sigmoid_cross_entropy_with_logits(logits, targets, name=None):
name
=
name
)
def
weighted_cross_entropy_with_logits
(
logits
,
targe
ts
,
pos_weight
,
name
=
None
):
def
weighted_cross_entropy_with_logits
(
targets
,
logi
ts
,
pos_weight
,
name
=
None
):
"""Computes a weighted cross entropy.
This is like `sigmoid_cross_entropy_with_logits()` except that `pos_weight`,
...
...
@@ -198,8 +198,8 @@ def weighted_cross_entropy_with_logits(logits, targets, pos_weight, name=None):
`logits` and `targets` must have the same type and shape.
Args:
logits: A `Tensor` of type `float32` or `float64`.
targets: A `Tensor` of the same type and shape as `logits`.
logits: A `Tensor` of type `float32` or `float64`.
pos_weight: A coefficient to use on the positive examples.
name: A name for the operation (optional).
...
...
tensorflow/python/ops/nn_xent_test.py
浏览文件 @
7aafb97f
...
...
@@ -119,7 +119,7 @@ class WeightedCrossEntropyTest(tf.test.TestCase):
def
testConstructionNamed
(
self
):
with
self
.
test_session
():
logits
,
targets
,
pos_weight
,
_
=
self
.
_Inputs
()
loss
=
tf
.
nn
.
weighted_cross_entropy_with_logits
(
logits
,
targe
ts
,
loss
=
tf
.
nn
.
weighted_cross_entropy_with_logits
(
targets
,
logi
ts
,
pos_weight
,
name
=
"mybce"
)
self
.
assertEqual
(
"mybce"
,
loss
.
op
.
name
)
...
...
@@ -127,7 +127,7 @@ class WeightedCrossEntropyTest(tf.test.TestCase):
for
use_gpu
in
[
True
,
False
]:
with
self
.
test_session
(
use_gpu
=
use_gpu
):
logits
,
targets
,
pos_weight
,
losses
=
self
.
_Inputs
(
dtype
=
tf
.
float32
)
loss
=
tf
.
nn
.
weighted_cross_entropy_with_logits
(
logits
,
targe
ts
,
loss
=
tf
.
nn
.
weighted_cross_entropy_with_logits
(
targets
,
logi
ts
,
pos_weight
)
np_loss
=
np
.
array
(
losses
).
astype
(
np
.
float32
)
tf_loss
=
loss
.
eval
()
...
...
@@ -138,7 +138,7 @@ class WeightedCrossEntropyTest(tf.test.TestCase):
with
self
.
test_session
(
use_gpu
=
use_gpu
):
logits
,
targets
,
pos_weight
,
losses
=
self
.
_Inputs
(
dtype
=
tf
.
float32
,
sizes
=
[
2
,
2
,
2
])
loss
=
tf
.
nn
.
weighted_cross_entropy_with_logits
(
logits
,
targe
ts
,
loss
=
tf
.
nn
.
weighted_cross_entropy_with_logits
(
targets
,
logi
ts
,
pos_weight
)
np_loss
=
np
.
array
(
losses
).
astype
(
np
.
float32
)
tf_loss
=
loss
.
eval
()
...
...
@@ -148,7 +148,7 @@ class WeightedCrossEntropyTest(tf.test.TestCase):
sizes
=
[
4
,
2
]
with
self
.
test_session
():
logits
,
targets
,
pos_weight
,
_
=
self
.
_Inputs
(
sizes
=
sizes
)
loss
=
tf
.
nn
.
weighted_cross_entropy_with_logits
(
logits
,
targe
ts
,
loss
=
tf
.
nn
.
weighted_cross_entropy_with_logits
(
targets
,
logi
ts
,
pos_weight
)
err
=
tf
.
test
.
compute_gradient_error
(
logits
,
sizes
,
loss
,
sizes
)
print
(
"logistic loss gradient err = "
,
err
)
...
...
@@ -156,7 +156,7 @@ class WeightedCrossEntropyTest(tf.test.TestCase):
def
testShapeError
(
self
):
with
self
.
assertRaisesRegexp
(
ValueError
,
"must have the same shape"
):
tf
.
nn
.
weighted_cross_entropy_with_logits
([
[
2
,
1
]],
[
1
,
2
,
3
],
2.0
)
tf
.
nn
.
weighted_cross_entropy_with_logits
([
1
,
2
,
3
],
[[
2
,
1
]
],
2.0
)
if
__name__
==
"__main__"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录