GenAIDevTOProd commited on
Commit
01a6f4b
·
verified ·
1 Parent(s): d191cb2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -2
README.md CHANGED
@@ -33,7 +33,26 @@ Available on **PyPI**: [torchlosses](https://pypi.org/project/torchlosses/)
33
 
34
  Naga Adithya Kaushik (GenAIDevTOProd)
35
 
36
- ## 📦 Installation
37
 
38
  ```bash
39
- pip install torchlosses
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  Naga Adithya Kaushik (GenAIDevTOProd)
35
 
36
+ ## Installation
37
 
38
  ```bash
39
+ pip install torchlosses
40
+
41
+ ## Usage
42
+
43
+ import torch
44
+ from torchlosses import FocalLoss, DiceLoss
45
+
46
+ # Focal Loss for classification
47
+ inputs = torch.randn(4, 5, requires_grad=True) # logits for 5 classes
48
+ targets = torch.randint(0, 5, (4,))
49
+ criterion = FocalLoss()
50
+ loss = criterion(inputs, targets)
51
+ print("Focal Loss:", loss.item())
52
+
53
+ # Dice Loss for segmentation
54
+ inputs = torch.randn(4, 1, 8, 8)
55
+ targets = torch.randint(0, 2, (4, 1, 8, 8))
56
+ criterion = DiceLoss()
57
+ loss = criterion(inputs, targets)
58
+ print("Dice Loss:", loss.item())