keras-core: possible bug: code working with tensorflow/jax backends but not with pytorch

PR #565 While trying to convert the compact convolution transformer to backend agnostic, I am facing issue working with the PyTorch backend. The model works with tensorflow/jax backends but throws an error with PyTorch.

Error for PyTorch backend: RuntimeError: Trying to backward through the graph a second time (or directly access saved tensors after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved tensors after calling backward.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 26 (26 by maintainers)

Most upvoted comments

you should do git clone https://github.com/keras-team/keras-core.git, python keras-core/pip_build.py --install

This is a great idea, we should try that.

I’ve applied this fix, let me know if it fixes your problem.

The problem is likely with the preprocessing part, CCTTokenizer. Try moving that out of the model?

I strongly suspect the error message is completely misleading, and that the error has to do with the fact that non-differentiable data augmentation ops are included in the model. Can you try moving the data augmentation / preprocessing logic outside of the model?

Thanks for the report. Can you run keras.config.disable_traceback_filtering() and then post the full stack trace?