UserWarning: size_average and reduce args will be deprecated, please use reduction='none' instead. warnings.warn(warning.format(ret))

I am getting this warning without any line number so I am unsure which line of code it relates to. Could you please shed some light on this?

UserWarning: size_average and reduce args will be deprecated, please use reduction='mean' instead.

I would like to know where I am expected to used the following?
reduction='none'

Full line of warning:

/home/jalal/research/venv/dpcc/lib/python3.8/site-packages/torch/nn/_reduction.py:42: UserWarning: size_average and reduce args will be deprecated, please use reduction='none' instead.
  warnings.warn(warning.format(ret))

The dpcc virt env python is:

$ python
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.10.1+cu113'

and

$ lsb_release -a
LSB Version:	core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.3 LTS
Release:	20.04
Codename:	focal

and

$ uname -a
Linux echo 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

This warning is raised if you use the deprecated reduce or size_average argument in a criterion.
Based on your last posts (e.g. this one) you are using:
``python

self.criterion = nn.BCEWithLogitsLoss(reduce=False)
1 Like

Gotcha, thank you.
Changed
self.criterion = nn.BCEWithLogitsLoss(reduce=False) # weighted loss
to
self.criterion = nn.BCEWithLogitsLoss(reduction='none') # weighted loss
based on your suggestion.