Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#381 Feature/sg 000 connect to lab

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/sg-000_connect_to_lab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  1. from enum import Enum
  2. import torch
  3. from typing import Union
  4. class LossReduction(Enum):
  5. MEAN = "mean"
  6. SUM = "sum"
  7. NONE = "none"
  8. def apply_reduce(loss: torch.Tensor, reduction: Union[LossReduction, str]):
  9. if reduction == LossReduction.MEAN.value:
  10. loss = loss.mean()
  11. elif reduction == LossReduction.SUM.value:
  12. loss = loss.sum()
  13. elif not LossReduction.NONE.value:
  14. raise ValueError(f"Reduction mode is not supported, expected options are ['mean', 'sum', 'none']"
  15. f", found {reduction}")
  16. return loss
Discard
Tip!

Press p or to see the previous file or, n or to see the next file