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 23a8059 commit e878137
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion returnn/frontend/math_.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def log(a: Tensor) -> 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))
eps = {"float16": 6e-08, "bfloat16": 9.1835e-41, "float32": 1.4013e-45, "float64": 4.9407e-324}[a.dtype]
# noinspection PyProtectedMember
return a._raw_backend.safe_log(a, eps=eps)

Expand Down

0 comments on commit e878137

Please sign in to comment.