diff --git a/src/deepproblog/semiring/graph_semiring.py b/src/deepproblog/semiring/graph_semiring.py index 0c4eac77..ff5fe828 100644 --- a/src/deepproblog/semiring/graph_semiring.py +++ b/src/deepproblog/semiring/graph_semiring.py @@ -113,9 +113,9 @@ def cross_entropy( ) else: if target == 1.0: - loss = -torch.log(p) * weight + loss = -torch.log(p + eps) * weight elif target == 0.0: - loss = -torch.log(1.0 - p) * weight + loss = -torch.log(1.0 - p + eps) * weight else: loss = ( -(