File "/home/username/anaconda3/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 433, in forward reduce=self.reduce)
File "/home/username/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py", line 1483, in binary_cross_entropy
return torch._C._nn.binary_cross_entropy(input, target, weight, size_average, reduce)
RuntimeError: reduce failed to synchronize: device-side assert triggered
答案 0 :(得分:1)
在使用cuda
时,您可能会遇到此通用错误,它不是很有帮助。尝试改用cpu
设备device = torch.device("cpu")
来查看实际的错误堆栈跟踪。
在我的情况下,此问题是由于二进制互熵期望输入值介于0〜1之间而引起的,但是我发送的值介于-1和1之间。对输出应用sigmoid
可解决该问题