🐍 Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
docs: add structural docstrings to kornia.losses.dice
heckkkerrr9f370b0945fa
diff --git a/kornia/losses/dice.py b/kornia/losses/dice.pyindex 9833a4d79..32ec86f3c 100644--- a/kornia/losses/dice.py+++ b/kornia/losses/dice.py@@ -15,6 +15,8 @@# limitations under the License.#+"""Module containing the Sørensen-Dice Coefficient loss."""+from __future__ import annotationsfrom typing import Optional@@ -204,6 +206,7 @@ class DiceLoss(nn.Module):weight: Optional[torch.Tensor] = None,ignore_index: Optional[int] = -100,) -> None:+ """Initialize the DiceLoss module."""super().__init__()self.average = averageself.eps = eps@@ -211,4 +214,13 @@ class DiceLoss(nn.Module):self.ignore_index = ignore_indexdef forward(self, pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor:+ """Compute the Sørensen-Dice Coefficient loss.++ Args:+ pred: the prediction tensor.+ target: the target tensor.++ Returns:+ The computed loss.+ """return dice_loss(pred, target, self.average, self.eps, self.weight, self.ignore_index)