Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two warnings #676

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions thinc/backends/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,8 @@ def erf(self, X: FloatsType) -> FloatsType:
return out

def sechsq(self, X: FloatsType) -> FloatsType:
# Avoid overflow in cosh. Clipping at |20| has an error of 1.7e-17.
X = self.xp.clip(X, -20.0, 20.0)
return (1 / self.xp.cosh(X)) ** 2

def gelu_approx(self, X: FloatsType, inplace: bool = False) -> FloatsType:
Expand Down
2 changes: 1 addition & 1 deletion thinc/tests/backends/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def torch_hard_swish_mobilenet(x):
return torch.nn.functional.hardswish(x)

def torch_sigmoid(x):
return torch.nn.functional.sigmoid(x)
return torch.sigmoid(x)

# https://github.com/huggingface/transformers/blob/master/src/transformers/activations.py#L37
def torch_gelu_approx(x):
Expand Down