-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
8000
Show file tree
Hide file tree
Feb 18, 2024
Feb 18, 2024
Feb 18, 2024
Feb 27, 2024
Feb 29, 2024
Feb 29, 2024
tensorflow
: add tensorflow.keras.activations
members
#11444
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
Merged
JelleZijlstra
merged 6 commits into
python:main
from
hoel-bagard:hoel/add_tf_keras_activations
Mar 1, 2024
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
90676e6
add tf.keras.activations members
hoel-bagard 1d7efea
Restrict activation input type.
hoel-bagard c27e35c
use _ActivationInput alias
hoel-bagard 04e6a5b
Merge branch 'main' into hoel/add_tf_keras_activations
rchen152 d25b89f
fix: add dict as return type of serialize.
hoel-bagard dfe2c42
Update stubs/tensorflow/tensorflow/keras/activations.pyi
hoel-bagard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
add tf.keras.activations members
- Loading branch information
commit 90676e693631f8b42e3d6e2ac8cfb413f782b815
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,34 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Callable | ||
from typing import Any | ||
from typing_extensions import TypeAlias | ||
|
||
from tensorflow import Tensor | ||
from tensorflow._aliases import FloatDataSequence, FloatTensorCompatible, Integer | ||
|
||
# The implementation uses isinstance so it must be dict and not any Mapping. | ||
_Activation: TypeAlias = str | None | Callable[[Tensor], Tensor] | dict[str, Any] | ||
|
||
def deserialize( | ||
name: str, custom_objects: dict[str, Callable[..., Any]] | None = None, use_legacy_format: bool = False | ||
) -> Callable[..., Any]: ... | ||
def elu(x: FloatTensorCompatible, alpha: FloatTensorCompatible | FloatDataSequence = 1.0) -> Tensor: ... | ||
def exponential(x: FloatTensorCompatible) -> Tensor: ... | ||
def gelu(x: FloatTensorCompatible, approximate: bool = False) -> Tensor: ... | ||
def get(identifier: _Activation) -> Callable[[Tensor], Tensor]: ... | ||
def __getattr__(name: str) -> Incomplete: ... | ||
def hard_sigmoid(x: FloatTensorCompatible) -> Tensor: ... | ||
def linear(x: FloatTensorCompatible) -> Tensor: ... | ||
def mish(x: FloatTensorCompatible) -> Tensor: ... | ||
def relu( | ||
x: FloatTensorCompatible | FloatDataSequence, | ||
alpha: FloatTensorCompatible = 0.0, | ||
max_value: FloatTensorCompatible | FloatDataSequence | None = None, | ||
threshold: FloatTensorCompatible | FloatDataSequence = 0.0, | ||
) -> Tensor: ... | ||
def selu(x: FloatTensorCompatible | FloatDataSequence) -> Tensor: ... # x here cannot be an int. | ||
def serialize(activation: Callable[..., Any], use_legacy_format: bool = False) -> str: ... | ||
def sigmoid(x: FloatTensorCompatible | FloatDataSequence) -> Tensor: ... # x here cannot be an int. | ||
def softmax(x: Tensor, axis: Integer = -1) -> Tensor: ... | ||
def softplus(x: FloatTensorCompatible | FloatDataSequence) -> Tensor: ... # x here cannot be an int. | ||
def softsign(x: 3DFD FloatTensorCompatible | FloatDataSequence) -> Tensor: ... # x here cannot be an int. | ||
def swish(x: FloatTensorCompatible | FloatDataSequence) -> Tensor: ... # x here cannot be an int. | ||
def tanh(x: FloatTensorCompatible | FloatDataSequence) -> Tensor: ... # x here cannot be an int. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can also return a dict:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JelleZijlstra Thanks for pointing it out, I've fixed it in d25b89f. Do you have a method / tool to find this kind of errors ?
For this particular function, looking at the source code would have made it clear that the return type could be a dict. Is it how you found out about it ?
When doing the TensorFlow stubs, I usually try a few inputs, but I can't test everything, so I often rely on what the docs say 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just by trying it out. I didn't do that for all functions, I think at first I was mostly curious what this function would do with a builtin.