Skip to content

Commit

Permalink
RF safe_log, better default eps
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Oct 18, 2023
1 parent 1300e90 commit 23a8059
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion returnn/frontend/math_.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,10 @@ def log(a: Tensor) -> Tensor:
return a._raw_backend.activation(a, "log")


def safe_log(a: Tensor, *, eps: float = 1e-7) -> Tensor:
def safe_log(a: Tensor, *, eps: Optional[float] = None) -> Tensor:
"""safe_log"""
if eps is None:
eps = numpy.nextafter(numpy.array(0, dtype=a.dtype), numpy.array(1, dtype=a.dtype))
# noinspection PyProtectedMember
return a._raw_backend.safe_log(a, eps=eps)

Expand Down

0 comments on commit 23a8059

Please sign in to comment.