使用多标签分类/分类的时候遇到的问题

在进行多标签分类时遇到了RuntimeError: the derivative for 'target' is not implemented,原因是输出未通过sigmoid激活函数,导致设备侧断言触发。错误详细堆栈信息指向了torch的binary_cross_entropy函数。解决方案可以检查输入和标签的顺序,并确保正确应用激活函数。
摘要由CSDN通过智能技术生成

RuntimeError: reduce failed to synchronize: cudaErrorAssert: device-side assert triggered

 

输出结果没有过sigmoid,引发断言错误

https://stackoverflow.com/questions/60022388/pytorch-runtimeerror-reduce-failed-to-synchronize-cudaerrorassert-device-sid

 

该函数第一个参数为Predict,第二个是label,如果传错顺序会报错

  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 498, in forward
    return F.binary_cross_entropy(input, target, weight=self.weight, reduction=self.reduction)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/functional.py", line 2077, in binary_cross_entropy
    input, target, weight, reduction_enum)


RuntimeError: the derivative for 'target' is not implemented

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值