-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add Tensorflow stubs #13433
base: main
Are you sure you want to change the base?
Add Tensorflow stubs #13433
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -442,4 +442,21 @@ class GaussianDropout(Layer[tf.Tensor, tf.Tensor]): | |
name: str | None = None, | ||
) -> None: ... | ||
|
||
class MaxPooling2D(Layer[tf.Tensor, tf.Tensor]): | ||
def __init__( | ||
self, | ||
pool_size: int | tuple[int, int] = (2, 2), | ||
strides: int | tuple[int, int] | None = None, | ||
padding: Literal["valid", "same"] = "valid", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might not be able to type this as a literal, the docs mention it's case-insensitive https://www.tensorflow.org/api_docs/python/tf/keras/layers/MaxPool2D#args there's examples of code that pass the value in all caps https://github.com/search?q=padding%3D%22valid%22+language%3APython+MaxPool2D&type=code |
||
data_format: None | Literal["channels_last", "channels_first"] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
name: str | None = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation seems to accept https://github.com/keras-team/keras/blob/v3.3.3/keras/src/layers/pooling/max_pooling2d.py#L96 |
||
) -> None: ... | ||
|
||
MaxPool2D = MaxPooling2D | ||
|
||
class GlobalAveragePooling2D(Layer[tf.Tensor, tf.Tensor]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar comments as above re: ordering of |
||
def __init__(self, data_format: None | Literal["channels_last", "channels_first"] = None, keepdims: bool = False) -> None: ... | ||
|
||
GlobalAvgPool2D = GlobalAveragePooling2D | ||
|
||
def __getattr__(name: str) -> Incomplete: ... |
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.
In the implementation this doesn't extend Layer directly, it extends BasePooling
https://github.com/keras-team/keras/blob/v3.3.3/keras/src/layers/pooling/base_pooling.py