Plans to enable eager execution from TF 2.0?
bburns632 opened this issue · comments
Hi there,
Love this package. It works swimmingly in TensorFlow 1.0 or TensorFlow 2.0 in compatibility mode (tf.compat.v1.disable_eager_execution()
). Are there any plans to upgrade this package to work in TF 2.0 (with eager execution)?
I believe that would primarily mean using tf.GradientTape()
.
This is on tensorflow==2.3.1, python==3.7.9, and keract==4.3.2
I am attempting keract.get_gradients_of_activations()
and get this message:
Exception: Disable TF eager mode to use get_gradients.
Add this command at the beginning of your script:
tf.compat.v1.disable_eager_execution()
If I do this, it works, but I would like to avoid this as the rest of my package is written in TF 2.0 (and assumes TF 2.0 capabilities) .
@bburns632 thanks! Really appreciate!
Yes you are right at the moment, the eager mode has to be disabled in order to use this library.
I'll try to work on this asap!
PR link: #123.
I tried a couple of hours but still unsuccessful to move to full eager. Some functionalities like gradients work but gradients of activations and some corner cases such that nested models don't work anymore.
But I can release a version without nested models and without the gradients of the activations. I'll see what's the best way to do that.
@bburns632 I pushed a nightly version to PyPi
pip install keract-nightly
Try and tell me how do you like it.
@philipperemy Thank you so much for this very quick accommodation! A little sheepishly, I need to ask how to import this nightly version. The pip install works fine (keract-nightly==5.1; no keract installed), but import keract
and import keract_nightly
both seem to fail in script.
No problem! Try:
pip uninstall -y keract
pip install keract-nightly
python
then: import keract
. The functions have the same signature!
Thanks. That's what I tried. It must have been something odd with my environment. Starting from a new environment, it works great. Thanks again!
conda create --name keractN python=3.7 pip tensorflow
conda activate keractN
pip install keract-nightly
python
Alright perfect! It's very alpha work so not all the functionalities will work. Good luck!
Damn it I am getting this error 'RuntimeError: Attempting to capture an EagerTensor without building a function.'
`tf.compat.v1.disable_eager_execution()
model.optimizer.get_gradients(model.losses,model.trainable_weights)
`