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

[Feature suggestion] Naming einops keras layers #216

Closed
Sangohe opened this issue Oct 8, 2022 · 1 comment
Closed

[Feature suggestion] Naming einops keras layers #216

Sangohe opened this issue Oct 8, 2022 · 1 comment

Comments

@Sangohe
Copy link

Sangohe commented Oct 8, 2022

Hello, it would be really nice if one could name the eniops layers just like any other keras layer. Right now, the following code triggers an error.

from einops.layers.tensorflow import Rearrange

tf.keras.Sequential([
    tf.keras.Input((224, 224, 3), name="inputs"),
    Rearrange("b h w c -> b c h w", name="rearrange_layer_1"),
])

The error goes away if we do not name the einops layer.

from einops.layers.tensorflow import Rearrange

tf.keras.Sequential([
    tf.keras.Input((224, 224, 3), name="inputs"),
    Rearrange("b h w c -> b c h w"),
])

Naming layers is very useful in keras, specially when using Functional models, to extract intermediate representations or to add new nodes to the graph. This process of extracting nodes is done by accessing the model's layer with model.get_layer(name).

@Sangohe Sangohe changed the title [Feature suggestion] [Feature suggestion] Naming einops keras layers Oct 8, 2022
@arogozhnikov
Copy link
Owner

From looking at implementation I believe you can use

layer._init_set_name('whatever')

Did not check though.

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

No branches or pull requests

2 participants