How to get pixel-wise BCELoss of an end to end framework?

username: Mata_Fu
cooked: <p>I want to get the pixel-wise BCELoss because some pixels don’t have ground truth. So I want to set the loss of those unlabeled pixels to 0.<br>
But it seems like the current BCELoss function can just provide the sum or average?</p>
<blockquote>
<p>class torch.nn.BCELoss(weight=None, size_average=True)<br>
Parameters:	<br>
weight (Tensor, optional) – a manual rescaling weight given to the loss of each batch element. If given, has to be a Tensor of size “nbatch”.<br>
size_average (bool, optional) – By default, the losses are averaged over observations for each minibatch. However, if the field size_average is set to False, the losses are instead summed for each minibatch. Default: True</p>
</blockquote>

username: ptrblck
cooked: <p>Which PyTorch version are you using?<br>
There should be a <code>reduce</code> argument in the current version.<br>
Setting <code>reduce=False</code> will give your the desired loss.</p>

username: Mata_Fu
cooked: <p>What I am using is 0.3.0. I can’t install the latest version on our server with several days’ trials.<img src="https://discuss.pytorch.org/images/emoji/apple/rofl.png?v=5" title=":rofl:" class="emoji" alt=":rofl:"></p>

username: ptrblck
cooked: <p>Why not? Do you get an error?</p>

username: Mata_Fu
cooked: <p>Yes! Thank you for reminding me about my failed installation.</p><aside class="quote quote-modified" data-post="1" data-topic="14918">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mata_fu/48/9814_2.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/install-problem-of-the-lastest-pytorch-version/14918">Install problem of the lastest pytorch version</a> <a class="badge-category__wrapper " href="/c/vision/5"><span data-category-id="5" data-drop-close="true" class="badge-category " title="Topics related to either pytorch/vision or vision research related topics"><span class="badge-category__name">vision</span></span></a>
  </div>
  <blockquote>
    I met a problem while installing pytorch 

cmake: relocation error: cmake: symbol ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareERKS4, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference 

I searched online and found solutions that I should upgrade my ubuntu14.04 to 16. But I can’t do this on the server because I’m not the only one use it and I don’t have the administrator permissions. 
Can someone help? 
my conda env: 

packages in environment at /h…
  </blockquote>
</aside>


username: Jeeyung_Kim
cooked: <p>Hi,</p>
<p>I thought even though setting <code>reduce=False</code> in bce loss, I sum all losses of pixels but just do not average or not sum of loss of  “batch”.</p>
<p>If I am using <code>reduce=False</code>, is it right that I don’t make summation of loss of pixels?</p>
<p>Thank you in advance.</p>

username: ptrblck
cooked: <p>If you are using <code>reduction='none'</code> (which is the new keyword), the loss won’t be reduced in any dimension:</p>
<pre><code class="lang-python">x = torch.randn(2, 3, 4, 5, requires_grad=True)
y = torch.randn(2, 3, 4, 5)
criterion = nn.BCEWithLogitsLoss(reduction='none')
loss = criterion(x, y)
print(loss.shape)
&gt; torch.Size([2, 3, 4, 5])
</code></pre>