Thank you! We'll be in touch ASAP.
Something went wrong, please try again or contact us directly at contact@dagshub.com
Deci-AI:master
deci-ai:feature/sg-000_connect_to_lab
from enum import Enum import torch from typing import Union class LossReduction(Enum): MEAN = "mean" SUM = "sum" NONE = "none" def apply_reduce(loss: torch.Tensor, reduction: Union[LossReduction, str]): if reduction == LossReduction.MEAN.value: loss = loss.mean() elif reduction == LossReduction.SUM.value: loss = loss.sum() elif not LossReduction.NONE.value: raise ValueError(f"Reduction mode is not supported, expected options are ['mean', 'sum', 'none']" f", found {reduction}") return loss
Press p or to see the previous file or, n or to see the next file