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

Checkpointing with collections raising exception in Keras #28

Open
skottapa opened this issue Aug 6, 2018 · 1 comment
Open

Checkpointing with collections raising exception in Keras #28

skottapa opened this issue Aug 6, 2018 · 1 comment

Comments

@skottapa
Copy link

skottapa commented Aug 6, 2018

Hi,

A TF newbie here. Am trying to use a pre-trained Keras Resnet-50 model on very large biological images(3000x4000 pix) of larvae. Since the image size is huge have to resort to gradient checkpointing.

have done the requisite monkey patching

import memory_saving_gradients K.__dict__['gradients']=memory_saving_gradients.gradients_collection

I have manually defined a collection of all the checkpoint nodes like so

[tf.add_to_collection("checkpoints",base_model.get_layer(i).get_output_at(0)) for i in ["add_4","add_8","add_12","add_16"]]

However I get the following exception

File "/home/satish/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/optimizers.py", line 244, in get_updates grads = self.get_gradients(loss, params) File "/home/satish/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/optimizers.py", line 78, in get_gradients grads = K.gradients(loss, params) File "/home/satish/anaconda3/envs/tensorflow/lib/python3.6/site-packages/memory_saving_gradients.py", line 31, in gradients_collection return gradients(ys, xs, grad_ys, checkpoints='collection', **kwargs) File "/home/satish/anaconda3/envs/tensorflow/lib/python3.6/site-packages/memory_saving_gradients.py", line 185, in gradients raise Exception('no checkpoints nodes found or given as input! ') Exception: no checkpoints nodes found or given as input!

Not sure why the collection is deemed empty.

Would greatly appreciate any feedback.

Thanks
Satish

@skottapa
Copy link
Author

skottapa commented Oct 16, 2018 via email

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

1 participant