Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
PaddleRec
提交
a96cefd6
P
PaddleRec
项目概览
BaiXuePrincess
/
PaddleRec
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleRec
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleRec
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a96cefd6
编写于
8月 19, 2019
作者:
R
rensilin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
loss_function(*output)
Change-Id: Iecc2518dc91b88125d29958ae78d5a8af3eb7eee
上级
ec85081f
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
5 addition
and
6 deletion
+5
-6
paddle/fluid/train/custom_trainer/feed/scripts/create_programs.py
...luid/train/custom_trainer/feed/scripts/create_programs.py
+3
-3
paddle/fluid/train/custom_trainer/feed/scripts/example.py
paddle/fluid/train/custom_trainer/feed/scripts/example.py
+2
-3
未找到文件。
paddle/fluid/train/custom_trainer/feed/scripts/create_programs.py
浏览文件 @
a96cefd6
...
...
@@ -30,10 +30,10 @@ class ModelBuilder:
list<Variable>: outputs
pass
def _loss_function(outputs):
def _loss_function(
*
outputs):
**This function is declared in the network_desc_path file, and will be set in initialize()**
Args:
outputs: the second result of inference()
*
outputs: the second result of inference()
Returns:
Variable: loss
...
...
@@ -97,7 +97,7 @@ class ModelBuilder:
with
fluid
.
program_guard
(
main_program
,
startup_program
):
inputs
,
outputs
=
self
.
_inference
()
test_program
=
main_program
.
clone
(
for_test
=
True
)
loss
,
labels
=
self
.
_loss_function
(
outputs
)
loss
,
labels
=
self
.
_loss_function
(
*
outputs
)
optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
1.0
)
params_grads
=
optimizer
.
backward
(
loss
)
...
...
paddle/fluid/train/custom_trainer/feed/scripts/example.py
浏览文件 @
a96cefd6
...
...
@@ -32,10 +32,10 @@ def inference():
ctr_output
=
fluid
.
layers
.
fc
(
net
,
1
,
act
=
'sigmoid'
,
name
=
'ctr'
)
return
[
cvm_input
],
[
ctr_output
]
def
loss_function
(
outputs
):
def
loss_function
(
ctr_output
):
"""
Args:
outputs: the second result of inference()
*
outputs: the second result of inference()
Returns:
Variable: loss
...
...
@@ -43,7 +43,6 @@ def loss_function(outputs):
list<Variable>: labels
"""
# TODO: calc loss here
ctr_output
,
=
outputs
label
=
fluid
.
layers
.
data
(
name
=
'label_ctr'
,
shape
=
ctr_output
.
shape
,
dtype
=
'float32'
)
loss
=
fluid
.
layers
.
square_error_cost
(
input
=
ctr_output
,
label
=
label
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录