-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add classes to tensorflow/keras/layers/__init__.pyi
#13433
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
base: main
Are you sure you want to change the base?
Conversation
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
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 comment
The 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
pool_size: int | tuple[int, int] = (2, 2), | ||
strides: int | tuple[int, int] | None = None, | ||
padding: Literal["valid", "same"] = "valid", | ||
data_format: None | Literal["channels_last", "channels_first"] = None, |
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.
Literal["channels_last", "channels_first"] | None
to match the style of the other optionals.
strides: int | tuple[int, int] | None = None, | ||
padding: Literal["valid", "same"] = "valid", | ||
data_format: None | Literal["channels_last", "channels_first"] = None, | ||
name: str | None = None, |
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.
The implementation seems to accept **kwargs
though I'm not sure the purpose
https://github.com/keras-team/keras/blob/v3.3.3/keras/src/layers/pooling/max_pooling2d.py#L96
@@ -442,4 +442,21 @@ class GaussianDropout(Layer[tf.Tensor, tf.Tensor]): | |||
name: str | None = None, | |||
) -> None: ... | |||
|
|||
class MaxPooling2D(Layer[tf.Tensor, tf.Tensor]): |
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
|
||
MaxPool2D = MaxPooling2D | ||
|
||
class GlobalAveragePooling2D(Layer[tf.Tensor, tf.Tensor]): |
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.
Similar comments as above re: ordering of | None
, and the base class here is BaseGlobalPooling
tensorflow/keras/layers/__init__.pyi
No description provided.