Cannot find BCEWithLogitsLoss()

I installed pytorch version 0.1.12_2

>>> torch.__version__
>>> '0.1.12_2'

but when I used torch.nn.BCEWithLogitsLoss(), it said:
AttributeError: 'module' object has no attribute 'BCEWithLogitsLoss'

anyone knows what’s wrong?

Thanks

nn.BCEWithLogitLoss was added in master branch(0.2.0), so you can’t use it in stable version(0.1.12_2).
Since BCEWithLogitLoss just combines Sigmoid layer and the BCELoss in one single class,
you can add one sigmoid layer before BCELoss Instead.

1 Like

@Jing thank you so much