Spaces:
Sleeping
Sleeping
Download src/train/losses.py from alphamike/GraphAttributeLearning: direct link, hf CLI and curl.
- Browser
- Download file 259 Bytes
-
https://huggingface.co/spaces/alphamike/GraphAttributeLearning/resolve/main/src/train/losses.py
- Command line
-
hf download hf://spaces/alphamike/GraphAttributeLearning/src/train/losses.py
-
curl -L -o losses.py https://huggingface.co/spaces/alphamike/GraphAttributeLearning/resolve/main/src/train/losses.py
259 Bytes
| from __future__ import annotations | |
| import torch | |
| def bce_logits_loss(logits: torch.Tensor, targets: torch.Tensor, pos_weight: torch.Tensor) -> torch.Tensor: | |
| loss_fn = torch.nn.BCEWithLogitsLoss(pos_weight=pos_weight) | |
| return loss_fn(logits, targets) | |