2.4K Star 8.2K Fork 4.4K

GVPMindSpore / mindspore

 / 详情

训练时支持损失函数多输出(包含网络正向执行结果)

TODO
RFC
创建于  
2022-08-06 15:53
name about labels
RFC Use this template for requirement to be discussed kind/feature or kind/enhancement
Requirement Use this template for Confirmed requirements kind/feature or kind/enhancement

Backgroud(背景信息)

在每个step训练后,希望能够通过损失函数拿到网络正向的执行结果,这样损失函数返回损失值的同时也会返回正向输出,然后通过训练网络返回,在每个step通过callback拿到。
类似如下:

  def construct(self, *inputs):
    loss = self.network(*inputs)
    other = None
    if isinstance(loss, tuple):
        loss = loss[0]
        other = loss[1:]
    sens = F.fill(loss.dtype, loss.shape, self.sens)
    grads = self.grad(self.network, self.weights)(*inputs, sens)
    grads = self.grad_reducer(grads)
    loss = F.depend(loss, self.optimizer(grads))
    if other is None:
        return loss
    return loss, other

Origin(信息来源)

  • Explain which department/team made this request so that its priority can be given.

Benefit / Necessity (价值/作用)

  • Describe/Explain the key value by fulfilling the request.

Design(设计方案)

  • Describe/Explain the general idea of the design. Pseudo-code is allowed

评论 (3)

zhangbuxue 创建了RFC
zhangbuxue 添加了
 
usability
标签
展开全部操作日志

Please assign maintainer to check this issue.
请为此issue分配处理人。
@zhangbuxue

Please add labels (comp or sig), also you can visit https://gitee.com/mindspore/community/blob/master/sigs/dx/docs/labels.md to find more.
为了让代码尽快被审核,请您为Pull Request打上 组件(comp)或兴趣组(sig) 标签,打上标签的PR可直接推送给责任人进行审核。
更多的标签可以查看https://gitee.com/mindspore/community/blob/master/sigs/dx/docs/labels.md
以组件相关代码提交为例,如果你提交的是data组件代码,你可以这样评论:
//comp/data
当然你也可以邀请data SIG组来审核代码,可以这样写:
//sig/data
另外你还可以给这个PR标记类型,例如是bugfix或者是特性需求:
//kind/bug or //kind/feature
恭喜你,你已经学会了使用命令来打标签,接下来就在下面的评论里打上标签吧!

zhangbuxue 修改了描述
zhangbuxue 修改了描述
zhangbuxue 负责人设置为wangnan39
zhangbuxue 修改了描述
wangnan39 添加协作者wangnan39
wangnan39 负责人wangnan39 修改为changzherui
wangnan39 取消协作者wangnan39

目前只能通过手动封装正向网络和损失函数来处理。

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(3)
7347217 changzherui 1584948547 6575112 zhangbuxue 1607593393
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore

搜索帮助