RuntimeError: all elements of input should be between 0 and 1

torch.nn.BCELoss(weight=None, reduction='mean')
这个类实现了二分类交叉熵。

使用这个类时要注意,输入值(不是分类)的范围要在 ( 0 , 1 ) (0,1)(0,1) 之间,否则会报错。
通常可以先使用 sigmoid或者softmax归一化 处理一下数据。

交叉熵描述了两个概率分布之间的距离,交叉熵越小说明两者之间越接近。

你可能感兴趣的:(RuntimeError: all elements of input should be between 0 and 1)