Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
b01f979b
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看板
未验证
提交
b01f979b
编写于
12月 09, 2022
作者:
K
kangguangli
提交者:
GitHub
12月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
replace cross_entropy in python/paddle/fluid/tests/unittests/*.py except test*.py (#48919)
上级
8b10773b
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
60 addition
and
20 deletion
+60
-20
python/paddle/fluid/tests/unittests/dist_allreduce_op.py
python/paddle/fluid/tests/unittests/dist_allreduce_op.py
+3
-1
python/paddle/fluid/tests/unittests/dist_ctr.py
python/paddle/fluid/tests/unittests/dist_ctr.py
+3
-1
python/paddle/fluid/tests/unittests/dist_fleet_ctr.py
python/paddle/fluid/tests/unittests/dist_fleet_ctr.py
+3
-1
python/paddle/fluid/tests/unittests/dist_fleet_heter_pipeline_ctr.py
...le/fluid/tests/unittests/dist_fleet_heter_pipeline_ctr.py
+3
-1
python/paddle/fluid/tests/unittests/dist_fleet_raw_program_optimizer.py
...fluid/tests/unittests/dist_fleet_raw_program_optimizer.py
+3
-1
python/paddle/fluid/tests/unittests/dist_fleet_raw_program_optimizer_fuse_allreduce.py
...ttests/dist_fleet_raw_program_optimizer_fuse_allreduce.py
+3
-1
python/paddle/fluid/tests/unittests/dist_fleet_sparse_embedding_ctr.py
.../fluid/tests/unittests/dist_fleet_sparse_embedding_ctr.py
+3
-1
python/paddle/fluid/tests/unittests/dist_mnist.py
python/paddle/fluid/tests/unittests/dist_mnist.py
+3
-1
python/paddle/fluid/tests/unittests/dist_mnist_batch_merge.py
...on/paddle/fluid/tests/unittests/dist_mnist_batch_merge.py
+3
-1
python/paddle/fluid/tests/unittests/dist_mnist_fp16_allreduce.py
...paddle/fluid/tests/unittests/dist_mnist_fp16_allreduce.py
+3
-1
python/paddle/fluid/tests/unittests/dist_mnist_lars.py
python/paddle/fluid/tests/unittests/dist_mnist_lars.py
+3
-1
python/paddle/fluid/tests/unittests/dist_se_resnext.py
python/paddle/fluid/tests/unittests/dist_se_resnext.py
+3
-1
python/paddle/fluid/tests/unittests/dist_text_classification.py
.../paddle/fluid/tests/unittests/dist_text_classification.py
+3
-1
python/paddle/fluid/tests/unittests/fleet_heter_ps_training.py
...n/paddle/fluid/tests/unittests/fleet_heter_ps_training.py
+3
-1
python/paddle/fluid/tests/unittests/parallel_dygraph_mnist.py
...on/paddle/fluid/tests/unittests/parallel_dygraph_mnist.py
+3
-1
python/paddle/fluid/tests/unittests/seresnext_net.py
python/paddle/fluid/tests/unittests/seresnext_net.py
+3
-1
python/paddle/fluid/tests/unittests/simple_nets.py
python/paddle/fluid/tests/unittests/simple_nets.py
+9
-3
python/paddle/fluid/tests/unittests/transformer_model.py
python/paddle/fluid/tests/unittests/transformer_model.py
+3
-1
未找到文件。
python/paddle/fluid/tests/unittests/dist_allreduce_op.py
浏览文件 @
b01f979b
...
...
@@ -77,7 +77,9 @@ class TestDistMnist2x2(TestDistRunnerBase):
# Train program
predict
=
cnn_model
(
images
)
cost
=
fluid
.
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
(
x
=
cost
)
# Evaluator
...
...
python/paddle/fluid/tests/unittests/dist_ctr.py
浏览文件 @
b01f979b
...
...
@@ -103,7 +103,9 @@ class TestDistCTR2x2(TestDistRunnerBase):
auc_var
,
batch_auc_var
,
auc_states
=
paddle
.
static
.
auc
(
input
=
predict
,
label
=
label
)
cost
=
fluid
.
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
(
x
=
cost
)
inference_program
=
paddle
.
fluid
.
default_main_program
().
clone
()
...
...
python/paddle/fluid/tests/unittests/dist_fleet_ctr.py
浏览文件 @
b01f979b
...
...
@@ -154,7 +154,9 @@ class TestDistCTR2x2(FleetDistRunnerBase):
input
=
predict
,
label
=
label
)
cost
=
fluid
.
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
(
x
=
cost
)
self
.
feeds
=
datas
...
...
python/paddle/fluid/tests/unittests/dist_fleet_heter_pipeline_ctr.py
浏览文件 @
b01f979b
...
...
@@ -123,7 +123,9 @@ class TestHeterPipelinePsCTR2x2(FleetDistHeterRunnerBase):
label
=
fluid
.
layers
.
cast
(
label
,
dtype
=
"int64"
)
predict
=
fluid
.
layers
.
fc
(
input
=
merge_layer
,
size
=
2
,
act
=
'softmax'
)
cost
=
fluid
.
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
(
x
=
cost
)
fluid
.
layers
.
Print
(
avg_cost
,
message
=
"avg_cost"
)
...
...
python/paddle/fluid/tests/unittests/dist_fleet_raw_program_optimizer.py
浏览文件 @
b01f979b
...
...
@@ -79,7 +79,9 @@ class TestFleetMetaOptimizerPrecision(TestDistRunnerBase):
# Train program
predict
=
cnn_model
(
images
)
cost
=
fluid
.
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
(
x
=
cost
)
# Evaluator
...
...
python/paddle/fluid/tests/unittests/dist_fleet_raw_program_optimizer_fuse_allreduce.py
浏览文件 @
b01f979b
...
...
@@ -79,7 +79,9 @@ class TestFleetMetaOptimizerFuseAllReducePrecision(TestDistRunnerBase):
# Train program
predict
=
cnn_model
(
images
)
cost
=
fluid
.
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
(
x
=
cost
)
# Evaluator
...
...
python/paddle/fluid/tests/unittests/dist_fleet_sparse_embedding_ctr.py
浏览文件 @
b01f979b
...
...
@@ -140,7 +140,9 @@ class TestDistCTR2x2(FleetDistRunnerBase):
acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
)
auc_var
,
_
,
_
=
paddle
.
static
.
auc
(
input
=
predict
,
label
=
label
)
cost
=
fluid
.
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
(
x
=
cost
)
self
.
feeds
=
datas
...
...
python/paddle/fluid/tests/unittests/dist_mnist.py
浏览文件 @
b01f979b
...
...
@@ -78,7 +78,9 @@ class TestDistMnist2x2(TestDistRunnerBase):
# Train program
predict
=
cnn_model
(
images
)
cost
=
fluid
.
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
(
x
=
cost
)
# Evaluator
...
...
python/paddle/fluid/tests/unittests/dist_mnist_batch_merge.py
浏览文件 @
b01f979b
...
...
@@ -43,7 +43,9 @@ class TestDistMnist2x2(TestDistRunnerBase):
# Train program
predict
=
cnn_model
(
images
)
cost
=
fluid
.
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
(
x
=
cost
)
# Evaluator
...
...
python/paddle/fluid/tests/unittests/dist_mnist_fp16_allreduce.py
浏览文件 @
b01f979b
...
...
@@ -37,7 +37,9 @@ class TestDistMnist2x2(TestDistRunnerBase):
# Train program
predict
=
cnn_model
(
images
)
cost
=
fluid
.
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
(
x
=
cost
)
# Evaluator
...
...
python/paddle/fluid/tests/unittests/dist_mnist_lars.py
浏览文件 @
b01f979b
...
...
@@ -34,7 +34,9 @@ class TestDistMnist2x2(TestDistRunnerBase):
# Train program
predict
=
cnn_model
(
images
)
cost
=
fluid
.
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
(
x
=
cost
)
# Evaluator
...
...
python/paddle/fluid/tests/unittests/dist_se_resnext.py
浏览文件 @
b01f979b
...
...
@@ -214,7 +214,9 @@ class DistSeResneXt2x2(TestDistRunnerBase):
# Train program
model
=
SE_ResNeXt
(
layers
=
50
)
out
=
model
.
net
(
input
=
image
,
class_dim
=
102
)
cost
=
fluid
.
layers
.
cross_entropy
(
input
=
out
,
label
=
label
)
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
out
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
acc_top1
=
paddle
.
static
.
accuracy
(
input
=
out
,
label
=
label
,
k
=
1
)
...
...
python/paddle/fluid/tests/unittests/dist_text_classification.py
浏览文件 @
b01f979b
...
...
@@ -132,7 +132,9 @@ class TestDistTextClassification2x2(TestDistRunnerBase):
# Train program
predict
=
conv_net
(
data
,
dict_dim
)
cost
=
fluid
.
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
(
x
=
cost
)
acc
=
paddle
.
static
.
accuracy
(
input
=
predict
,
label
=
label
)
inference_program
=
fluid
.
default_main_program
().
clone
()
...
...
python/paddle/fluid/tests/unittests/fleet_heter_ps_training.py
浏览文件 @
b01f979b
...
...
@@ -112,7 +112,9 @@ def net(batch_size=4, lr=0.01):
label
=
fluid
.
layers
.
cast
(
label
,
dtype
=
"int64"
)
predict
=
fluid
.
layers
.
fc
(
input
=
merge_layer
,
size
=
2
,
act
=
'softmax'
)
cost
=
fluid
.
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
(
x
=
cost
)
return
datas
,
avg_cost
...
...
python/paddle/fluid/tests/unittests/parallel_dygraph_mnist.py
浏览文件 @
b01f979b
...
...
@@ -95,7 +95,9 @@ class MNIST(fluid.dygraph.Layer):
x
=
self
.
_simple_img_conv_pool_2
(
x
)
x
=
paddle
.
reshape
(
x
,
shape
=
[
-
1
,
self
.
pool_2_shape
])
cost
=
self
.
_fc
(
x
)
loss
=
fluid
.
layers
.
cross_entropy
(
self
.
act
(
cost
),
label
)
loss
=
paddle
.
nn
.
functional
.
cross_entropy
(
self
.
act
(
cost
),
label
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_loss
=
paddle
.
mean
(
loss
)
return
avg_loss
...
...
python/paddle/fluid/tests/unittests/seresnext_net.py
浏览文件 @
b01f979b
...
...
@@ -170,7 +170,9 @@ def SE_ResNeXt50Small(use_feed):
)
# Classifier layer:
prediction
=
fluid
.
layers
.
fc
(
input
=
dropout
,
size
=
1000
,
act
=
'softmax'
)
loss
=
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
label
)
loss
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
)
loss
=
paddle
.
mean
(
loss
)
return
loss
...
...
python/paddle/fluid/tests/unittests/simple_nets.py
浏览文件 @
b01f979b
...
...
@@ -30,7 +30,9 @@ def simple_fc_net_with_inputs(img, label, class_num=10):
),
)
prediction
=
fluid
.
layers
.
fc
(
hidden
,
size
=
class_num
,
act
=
'softmax'
)
loss
=
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
label
)
loss
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
)
loss
=
paddle
.
mean
(
loss
)
return
loss
...
...
@@ -56,7 +58,9 @@ def batchnorm_fc_with_inputs(img, label, class_num=10):
hidden
=
paddle
.
static
.
nn
.
batch_norm
(
input
=
hidden
)
prediction
=
fluid
.
layers
.
fc
(
hidden
,
size
=
class_num
,
act
=
'softmax'
)
loss
=
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
label
)
loss
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
)
loss
=
paddle
.
mean
(
loss
)
return
loss
...
...
@@ -93,7 +97,9 @@ def bow_net(
fc_1
=
fluid
.
layers
.
fc
(
input
=
bow_tanh
,
size
=
hid_dim
,
act
=
"tanh"
)
fc_2
=
fluid
.
layers
.
fc
(
input
=
fc_1
,
size
=
hid_dim2
,
act
=
"tanh"
)
prediction
=
fluid
.
layers
.
fc
(
input
=
[
fc_2
],
size
=
class_dim
,
act
=
"softmax"
)
cost
=
fluid
.
layers
.
cross_entropy
(
input
=
prediction
,
label
=
label
)
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
prediction
,
label
=
label
,
reduction
=
'none'
,
use_softmax
=
False
)
avg_cost
=
paddle
.
mean
(
x
=
cost
)
return
avg_cost
...
...
python/paddle/fluid/tests/unittests/transformer_model.py
浏览文件 @
b01f979b
...
...
@@ -594,6 +594,8 @@ def transformer(
)
predict
=
paddle
.
nn
.
functional
.
softmax
(
predict
)
cost
=
layers
.
cross_entropy
(
input
=
predict
,
label
=
gold
)
cost
=
paddle
.
nn
.
functional
.
cross_entropy
(
input
=
predict
,
label
=
gold
,
reduction
=
'none'
,
use_softmax
=
False
)
weighted_cost
=
cost
*
weights
return
paddle
.
sum
(
weighted_cost
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录