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

Add Tensorflow stubs #13433

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add Tensorflow stubs #13433

wants to merge 2 commits into from

Conversation

MightyPiggie
Copy link

No description provided.

Copy link
Contributor

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",
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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]):
Copy link
Contributor

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]):
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants