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

request: type information for layers #19836

Open
ghsanti opened this issue Jun 11, 2024 · 4 comments
Open

request: type information for layers #19836

ghsanti opened this issue Jun 11, 2024 · 4 comments
Assignees
Labels

Comments

@ghsanti
Copy link

ghsanti commented Jun 11, 2024

Executing any of the layers, for example:

    z_in = Input(shape=(123,), name="name")

The return type is Unknown, which means we don't have hints for the methods of z_in.

Certainly we could do cast(KerasTensor,z_in) but that would need to be done with every layer, every time.

Any ideas @mehtamansi29 ?

@fchollet
Copy link
Member

In the example above, z_in has a dtype attribute which in this case has value "float32".

@ghsanti
Copy link
Author

ghsanti commented Jun 11, 2024

But I mean type information for type hints, currently z_in is marked as Unknown. This is from the blueprint of Input, for example:

(function) def Input(
    shape: Unknown | None = None,
    batch_size: Unknown | None = None,
    dtype: Unknown | None = None,
    sparse: Unknown | None = None,
    batch_shape: Unknown | None = None,
    name: Unknown | None = None,
    tensor: Unknown | None = None,
    optional: bool = False
) -> (Unknown | Any | list[Unknown])

This makes it difficult: -> (Unknown | Any | list[Unknown])

@fchollet

@ghsanti
Copy link
Author

ghsanti commented Jun 14, 2024

Linked issue was solved using Jedi (or a workaround for Pylance.)

But this issue isn't resolved yet i.e how to get typing information on class instances.

@ghsanti ghsanti changed the title Is it possible to get type information from the keras layers calls ? request: type information for layers Jun 17, 2024
@ghsanti
Copy link
Author

ghsanti commented Jun 25, 2024

Is this planned? Do you need help with it? @mehtamansi29

I'd find having this types quite useful since I'm new to Keras.

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

No branches or pull requests

3 participants