Uploaded image for project: 'AI Platform Core Components'
  1. AI Platform Core Components
  2. AIPCC-5687

Incorrect documentation for `BCEWithLogitsLoss` `weight`?

    • Icon: Story Story
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • None
    • PyTorch
    • None
    • PyTorch Sprint 17

        1. 📚 Documentation

      The documentation for the `weight` parameter for the `BCEWithLogitsLoss` class is:

      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`.

      This implies a vector of N

      However the documentation for `F.binary_cross_entropy_with_logits` is different, it states

      weight (Tensor, optional): a manual rescaling weight
      if provided it's repeated to match input tensor shape

      And `BCEWithLogitsLoss` simply forwards it's arguments to `F.binary_cross_entropy_with_logits`, so clearly "has to be a Tensor of size `nbatch` is incorrect".

      In my tests `weights` can be 1xC, 1x1, Nx1 or NxC (which I guess is what the `F.binary_cross_entropy_with_logits` docstring is implying). But it's not totally clear and I think the `BCEWithLogitsLoss` is incorrect.

      cc @svekars @brycebortree @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki @brianjo @kshitij12345

              rh-ee-chleonar Christopher Leonard
              rh-ee-chleonar Christopher Leonard
              PyTorch Core
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: