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

Any plan to add type annotations? #19453

Closed
gmdzy2010 opened this issue Apr 6, 2024 · 2 comments
Closed

Any plan to add type annotations? #19453

gmdzy2010 opened this issue Apr 6, 2024 · 2 comments
Assignees
Labels
keras-team-review-pending Pending review by a Keras team member.

Comments

@gmdzy2010
Copy link

It's very strange as I noticed:

from keras import layers, models

model = models.Sequential()

...

The type checker(of vscode) would consider the type of model instance as

(variable) model: Functional | Unknown

as a result, the code completion didn't work well even for some simple case:

...
layer_conv2d_1 = layers.Conv2D(
    32,
    (3, 3),
    activation="relu",
    input_shape=(28, 28, 1),
)

model.add(layer_conv2d_1)
...

method add couldn't be found.

type annotation may help us deal with those above.

Or some work around?

@sachinprasadhs sachinprasadhs added the keras-team-review-pending Pending review by a Keras team member. label Apr 9, 2024
@fchollet
Copy link
Member

fchollet commented Apr 9, 2024

It looks like VSCode is not able to determine that Sequential has a method add() -- even though it's right there in the Sequential class definition. Type annotations wouldn't help here. I would expect the code completion feature for properties/methods to use dir() and filter for public (no underscore) entries. Which should work here.

Are you able to pinpoint what exactly is causing this?

@fchollet
Copy link
Member

fchollet commented Apr 9, 2024

This should now be fixed!

@fchollet fchollet closed this as completed Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keras-team-review-pending Pending review by a Keras team member.
Projects
None yet
Development

No branches or pull requests

3 participants