google-research / tensorflow_constrained_optimization

Other
300 stars 50 forks source link

TypeError: _compute_gradients() got an unexpected keyword argument 'tape' #10

Open michiexile opened 3 years ago

michiexile commented 3 years ago

When trying to use TFCO - either for my own problem, or just reproducing the Proxy Lagrangian problem in the README - I get a TypeError:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-61c999c50081> in <module>
     15 
     16 for ii in xrange(1000):
---> 17   optimizer.minimize(problem, var_list=var_list)
     18 
     19 trained_weights = weights.numpy()

/usr/local/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/optimizer_v2/optimizer_v2.py in minimize(self, loss, var_list, grad_loss, name, tape)
    495     """
    496     grads_and_vars = self._compute_gradients(
--> 497         loss, var_list=var_list, grad_loss=grad_loss, tape=tape)
    498     return self.apply_gradients(grads_and_vars, name=name)
    499 

TypeError: _compute_gradients() got an unexpected keyword argument 'tape'

I am running (from pip list):

tensorflow                          2.4.1
tensorflow-constrained-optimization 0.2
michiexile commented 3 years ago

The code in the README that goes directly to tf.keras.optimizers.Adagrad without using the Lagrangian framework works well and produces the same output as cited in the README.

manan-paneri-99 commented 3 years ago

@michiexile Have you found any workaround for this?

Qdq315 commented 3 years ago

I have the same issue, but havn't fixed it. Any help?

kalashnov commented 2 years ago

Same for me

tensorflow==2.6.0
tensorflow-constrained-optimization==0.2
kalashnov commented 2 years ago

Hi, guys. In fact i found that the pip version of the packages is somehow missing this commit https://github.com/google-research/tensorflow_constrained_optimization/commit/d00faece9c12ae0919a9c30e311b2fb442289c22

So, installing the package from the repository directly would fix the problem

samlopezruiz commented 2 years ago

I have the same issue with

tensorflow==2.8.0
tensorflow-constrained-optimization==0.2
KokOpyo3 commented 2 years ago

I am also having this issue. Is there any update or a suggested workaround?

tensorflow==2.8.0 tensorflow-constrained-optimization==0.2

PL97 commented 1 year ago

Upgrading TensorFlow to 2.9.2 would fix the problem.