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

For People Who need > TF2.3 compatability #71

Open
Woodyet opened this issue Aug 3, 2022 · 7 comments
Open

For People Who need > TF2.3 compatability #71

Woodyet opened this issue Aug 3, 2022 · 7 comments

Comments

@Woodyet
Copy link

Woodyet commented Aug 3, 2022

Hello I have been using this library for a bit and have a slightly edited library that works for at least tensorflow 2.5

https://github.com/Woodyet/Pix2Pix_Auto_Prune/tree/master/Pix2Pix_Auto_Prune/Tensorflow2.5.0/kerassurgeon

Most of the updates are lifted from the pull requests here

It's not fully tested but I think someone more capable than me should clone that repo and make a keras-surgeon-2 as I don't think Ben is coming back to this

@Woodyet Woodyet changed the title For People Who need < TF2.3 compatability For People Who need > TF2.3 compatability Aug 3, 2022
@King-Of-Knights
Copy link

@Woodyet Thanks a a lot! I will test this on TF 2.7.0

@Woodyet
Copy link
Author

Woodyet commented Aug 17, 2022

The deleting of convtranspose is deffo broken, just notice the output_mask is set to None (which won't work if you have a model with subsequent layers)

@callum-b
Copy link

Thanks for working on this! Do you have a script example where you use this new library?

@christian-steinmeyer
Copy link

christian-steinmeyer commented Jul 18, 2023

I'm not sure quite yet, whether I'll go all the way with releasing a pip package etc., but if you're fine with a pip install via git repo, check out my fork. I've put in a bit of effort in getting everything tidy including all functional PRs from this repo and adding depthwise convolutions. I also added the option to provide your own implementations for any additional layers, you might need. I might add more layers, if I need them for my work.

pip install keras-surgeon@git+https://github.com/christian-steinmeyer/keras-surgeon.git

Disclaimer: Although I am working with TF 2.12 and seem to have no issues, no guarantees, that everything works 100% correct.

@Woodyet
Copy link
Author

Woodyet commented Jul 18, 2023

I am sure people can test for themselves, but I am pretty sure tensorflow changed some fundamental code infrastructure when going from 2.2 to 2.3.

Which was what broke this library. But thanks for working on it.

@christian-steinmeyer
Copy link

@Woodyet Do you know anything more specific / do you have any pointers to what leads you to this conclusion? Although original testing worked out great for me, I do experience some unexplained behavior now that I do more in depth tests.

For example, I prune units from dense layers that have zero weights, which shouldn't really affect the model output, but unfortunately, it does, although the relevant subset of weights (those not pruned, because they were not zero) is exactly as expected after the pruning.

@aidevmin
Copy link

aidevmin commented Jun 9, 2024

@christian-steinmeyer
Do you meet this 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 la mbda layer in the Functional Model. This error will also get raised if you try a sserting a symbolic input/output directly."

I used pre-trained MobileNetv1 model with changed number of classes. But I got this error. I used TF2.12.

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

5 participants