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

Keras symbolic inputs/outputs do not implement __len__. #61

Open
Linkstus opened this issue Aug 2, 2021 · 4 comments
Open

Keras symbolic inputs/outputs do not implement __len__. #61

Linkstus opened this issue Aug 2, 2021 · 4 comments

Comments

@Linkstus
Copy link

Linkstus commented Aug 2, 2021

I am not sure if I am using this correctly but I am trying to experiment with Kerassurgeon to delete and add layers. Currently me and my team are struggling to get the delete function from operations to work properly. Below is how the model is being created, and the final line is how we are trying to delete a layer.

model = Sequential()
model.add(Dense(12, input_dim = 8, activation = "relu"))
model.add(Dense(8, activation = "relu"))
model.add(Dense(1, activation = "sigmoid"))
model.compile(loss = "binary_crossentropy", optimizer = "adam", metrics = ["accuracy"])

model.fit(X, y, epochs = 150, batch_size = 10)

model = delete_layer(model, model.layers[1])

The issue comes about that when we go to do this we get the error.

TypeError: Keras symbolic inputs/outputs do not implement __len__. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. This error will also get raised if you try asserting a symbolic input/output directly.

Not really sure what is going on in this scenario. Any light on the issue would be helpful.

@maartenvds
Copy link

maartenvds commented Aug 4, 2021

I had the same error with TF2.4.0 and TF2.5.0. Downgrading to TF2.3.0 fixed the problem. I guess this repo needs an upgrade tot support the later TF releases.

@marcelroed
Copy link

Any updates on this?

@Linkstus
Copy link
Author

downgrading fixed this issue, but caused a few issues with the keras and tensorflow side of things.

@MT010104
Copy link

I had the same error with TF2.4.0 and TF2.5.0. Downgrading to TF2.3.0 fixed the problem. I guess this repo needs an upgrade tot support the later TF releases.

Downgrading cannot fix my problem😭😭😭

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

No branches or pull requests

4 participants