pytorch
9a5fed1b - Harmonize BCELoss example to F.binary_cross_entropy (#95178)

Commit
1 year ago
Harmonize BCELoss example to F.binary_cross_entropy (#95178) About that line: ``` torch.empty(3).random_(2) ``` * Since BCE supports targets in the interval [0, 1], a better example is to sample from uniform(0, 1), using `rand` * BCE supports multiple dimensions, and the example in `F.binary_cross_entropy` highlights it * `rand` is more well known than `random_`, which is a bit obscure (`rand` is in the [Random Sampling section in the docs](https://pytorch.org/docs/stable/torch.html#random-sampling)) * Chaining `empty` and `random_` gives binary values as floats, which is a weird way to get that result * Why do it in two steps when we have sampling functions that do it in a single step? Pull Request resolved: https://github.com/pytorch/pytorch/pull/95178 Approved by: https://github.com/albanD, https://github.com/kit1980
Author
Committer
Parents
Loading