Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
8035c6f2
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8035c6f2
编写于
12月 13, 2022
作者:
K
kangguangli
提交者:
GitHub
12月 13, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove reset reference in unittest for `fluid.layers.cross_entropy` (#49012)
上级
acee3dd3
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
105 addition
and
46 deletion
+105
-46
python/paddle/fluid/contrib/slim/tests/test_imperative_qat_matmul.py
...le/fluid/contrib/slim/tests/test_imperative_qat_matmul.py
+3
-1
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_fp16_allreduce_meta_optimizer.py
...lective/fleet/test_fleet_fp16_allreduce_meta_optimizer.py
+5
-2
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_graph_execution_meta_optimizer.py
...ective/fleet/test_fleet_graph_execution_meta_optimizer.py
+20
-8
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_graph_executor.py
...s/unittests/collective/fleet/test_fleet_graph_executor.py
+5
-2
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_lamb_meta_optimizer.py
...ttests/collective/fleet/test_fleet_lamb_meta_optimizer.py
+7
-4
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_lars_meta_optimizer.py
...ttests/collective/fleet/test_fleet_lars_meta_optimizer.py
+7
-4
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_meta_optimizer_base.py
...ttests/collective/fleet/test_fleet_meta_optimizer_base.py
+5
-2
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_pipeline_meta_optimizer.py
...ts/collective/fleet/test_fleet_pipeline_meta_optimizer.py
+5
-2
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_pipeline_meta_optimizer_with_recompute.py
...leet/test_fleet_pipeline_meta_optimizer_with_recompute.py
+5
-2
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_raw_program_meta_optimizer.py
...collective/fleet/test_fleet_raw_program_meta_optimizer.py
+2
-2
python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py
...luid/tests/unittests/dygraph_to_static/test_mobile_net.py
+5
-2
python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py
...addle/fluid/tests/unittests/dygraph_to_static/test_tsm.py
+6
-2
python/paddle/fluid/tests/unittests/ipu/test_cross_entropy2_op_ipu.py
...e/fluid/tests/unittests/ipu/test_cross_entropy2_op_ipu.py
+6
-2
python/paddle/fluid/tests/unittests/ipu/test_dy2static_ipu.py
...on/paddle/fluid/tests/unittests/ipu/test_dy2static_ipu.py
+4
-7
python/paddle/fluid/tests/unittests/test_layers.py
python/paddle/fluid/tests/unittests/test_layers.py
+20
-4
未找到文件。
python/paddle/fluid/contrib/slim/tests/test_imperative_qat_matmul.py
浏览文件 @
8035c6f2
...
...
@@ -173,7 +173,9 @@ class TestImperativeQatMatmul(unittest.TestCase):
label
=
fluid
.
dygraph
.
to_variable
(
y_data
)
out
=
lenet
(
img
)
acc
=
paddle
.
static
.
accuracy
(
out
,
label
)
loss
=
fluid
.
layers
.
cross_entropy
(
out
,
label
)
loss
=
paddle
.
nn
.
functional
.
cross_entropy
(
out
,
label
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_loss
=
paddle
.
mean
(
loss
)
avg_loss
.
backward
()
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_fp16_allreduce_meta_optimizer.py
浏览文件 @
8035c6f2
...
...
@@ -42,8 +42,11 @@ class TestFleetFP16CompressOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_graph_execution_meta_optimizer.py
浏览文件 @
8035c6f2
...
...
@@ -72,8 +72,11 @@ class TestFleetGraphExecutionMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
@@ -135,8 +138,11 @@ class TestFleetGraphExecutionMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
@@ -210,8 +216,11 @@ class TestFleetGraphExecutionMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
@@ -272,8 +281,11 @@ class TestFleetGraphExecutionMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_graph_executor.py
浏览文件 @
8035c6f2
...
...
@@ -59,8 +59,11 @@ class TestFleetGraphExecutionMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_lamb_meta_optimizer.py
浏览文件 @
8035c6f2
...
...
@@ -47,8 +47,11 @@ class TestFleetLambMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
@@ -122,8 +125,8 @@ class TestFleetLambMetaOptimizer(unittest.TestCase):
fc_1
=
paddle
.
fluid
.
layers
.
fc
(
input
=
input_x
,
size
=
64
,
act
=
'tanh'
)
fc_2
=
paddle
.
fluid
.
layers
.
fc
(
input
=
fc_1
,
size
=
64
,
act
=
'tanh'
)
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_lars_meta_optimizer.py
浏览文件 @
8035c6f2
...
...
@@ -47,8 +47,11 @@ class TestFleetLarsMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
@@ -127,8 +130,8 @@ class TestFleetLarsMetaOptimizer(unittest.TestCase):
fc_1
=
paddle
.
fluid
.
layers
.
fc
(
input
=
input_x
,
size
=
64
,
act
=
'tanh'
)
fc_2
=
paddle
.
fluid
.
layers
.
fc
(
input
=
fc_1
,
size
=
64
,
act
=
'tanh'
)
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_meta_optimizer_base.py
浏览文件 @
8035c6f2
...
...
@@ -43,8 +43,11 @@ class TestFleetMetaOptimizerBase(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_pipeline_meta_optimizer.py
浏览文件 @
8035c6f2
...
...
@@ -56,8 +56,11 @@ class TestFleetMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
return
avg_cost
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_pipeline_meta_optimizer_with_recompute.py
浏览文件 @
8035c6f2
...
...
@@ -52,8 +52,11 @@ class TestFleetMetaOptimizer(unittest.TestCase):
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_7
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/test_fleet_raw_program_meta_optimizer.py
浏览文件 @
8035c6f2
...
...
@@ -41,8 +41,8 @@ class TestFleetMetaOptimizer(unittest.TestCase):
fc_2
=
paddle
.
fluid
.
layers
.
fc
(
input
=
fc_1
,
size
=
64
,
act
=
'tanh'
)
prediction
=
paddle
.
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
2
,
act
=
'softmax'
)
cost
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
input_y
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py
浏览文件 @
8035c6f2
...
...
@@ -531,8 +531,11 @@ def train_mobilenet(args, to_static):
t_end
=
time
.
time
()
softmax_out
=
paddle
.
nn
.
functional
.
softmax
(
out
)
loss
=
fluid
.
layers
.
cross_entropy
(
input
=
softmax_out
,
label
=
label
loss
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
softmax_out
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_loss
=
paddle
.
mean
(
x
=
loss
)
acc_top1
=
paddle
.
static
.
accuracy
(
input
=
out
,
label
=
label
,
k
=
1
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py
浏览文件 @
8035c6f2
...
...
@@ -329,8 +329,12 @@ def train(args, fake_data_reader, to_static):
labels
=
to_variable
(
y_data
)
labels
.
stop_gradient
=
True
outputs
=
video_model
(
imgs
)
loss
=
fluid
.
layers
.
cross_entropy
(
input
=
outputs
,
label
=
labels
,
ignore_index
=-
1
loss
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
outputs
,
label
=
labels
,
ignore_index
=-
1
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_loss
=
paddle
.
mean
(
loss
)
acc_top1
=
paddle
.
static
.
accuracy
(
...
...
python/paddle/fluid/tests/unittests/ipu/test_cross_entropy2_op_ipu.py
浏览文件 @
8035c6f2
...
...
@@ -63,8 +63,12 @@ class TestBase(IPUOpTest):
label
=
paddle
.
static
.
data
(
name
=
self
.
feed_list
[
1
],
shape
=
self
.
feed_shape
[
1
],
dtype
=
'int64'
)
out
=
paddle
.
fluid
.
layers
.
cross_entropy
(
input
=
x
,
label
=
label
,
**
self
.
attrs
out
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
x
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
,
**
self
.
attrs
)
self
.
fetch_list
=
[
out
.
name
]
...
...
python/paddle/fluid/tests/unittests/ipu/test_dy2static_ipu.py
浏览文件 @
8035c6f2
...
...
@@ -49,12 +49,9 @@ class SimpleLayer(paddle.nn.Layer):
if
target
is
not
None
:
if
self
.
use_softmax
:
x
=
paddle
.
nn
.
functional
.
softmax
(
x
)
if
self
.
loss_op
:
loss
=
self
.
loss_op
(
x
,
target
)
else
:
loss
=
paddle
.
paddle
.
nn
.
functional
.
cross_entropy
(
x
,
target
,
reduction
=
'none'
,
use_softmax
=
False
)
loss
=
paddle
.
paddle
.
nn
.
functional
.
cross_entropy
(
x
,
target
,
reduction
=
'none'
,
use_softmax
=
False
)
if
self
.
use_reduction
:
loss
=
paddle
.
mean
(
loss
)
if
self
.
use_identity_loss
:
...
...
@@ -69,7 +66,7 @@ class TestBase(IPUD2STest):
self
.
set_data_feed
()
def
set_op_attrs
(
self
):
self
.
loss_op
=
paddle
.
fluid
.
layers
.
cross_entropy
pass
def
set_data_feed
(
self
):
self
.
data
=
paddle
.
uniform
((
8
,
3
,
10
,
10
),
dtype
=
'float32'
)
...
...
python/paddle/fluid/tests/unittests/test_layers.py
浏览文件 @
8035c6f2
...
...
@@ -2062,7 +2062,9 @@ class TestBook(LayerTest):
act
=
'softmax'
,
param_attr
=
[
"sftmax.w1"
,
"sftmax.w2"
],
)
cost
=
layers
.
cross_entropy
(
input
=
predict
,
label
=
label
)
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
predict
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_cost
=
paddle
.
mean
(
cost
)
return
avg_cost
...
...
@@ -2101,7 +2103,9 @@ class TestBook(LayerTest):
)
predict
=
layers
.
fc
(
input
=
conv_pool_2
,
size
=
10
,
act
=
"softmax"
)
cost
=
layers
.
cross_entropy
(
input
=
predict
,
label
=
label
)
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
predict
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_cost
=
paddle
.
mean
(
cost
)
return
avg_cost
...
...
@@ -2154,7 +2158,12 @@ class TestBook(LayerTest):
predict_word
=
layers
.
fc
(
input
=
hidden1
,
size
=
dict_size
,
act
=
'softmax'
)
cost
=
layers
.
cross_entropy
(
input
=
predict_word
,
label
=
next_word
)
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
predict_word
,
label
=
next_word
,
reduction
=
'none'
,
use_softmax
=
False
,
)
avg_cost
=
paddle
.
mean
(
cost
)
return
avg_cost
...
...
@@ -2366,7 +2375,14 @@ class TestBook(LayerTest):
x
=
self
.
_get_data
(
name
=
"x"
,
shape
=
[
30
,
10
],
dtype
=
"float32"
)
label
=
self
.
_get_data
(
name
=
"label"
,
shape
=
[
30
,
1
],
dtype
=
"int64"
)
mode
=
'channel'
out
=
layers
.
cross_entropy
(
x
,
label
,
False
,
4
)
out
=
paddle
.
nn
.
functional
.
cross_entropy
(
x
,
label
,
soft_label
=
False
,
ignore_index
=
4
,
reduction
=
'none'
,
use_softmax
=
False
,
)
return
out
def
make_uniform_random_batch_size_like
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录