pythontensorflowmachine-learninggoogle-colaboratorytf-agent

Error while importing tf_agents in google colab


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import abc
import tensorflow as tf
import numpy as np
import pandas as pd

from tf_agents.environments import py_environment
from tf_agents.environments import tf_environment
from tf_agents.environments import tf_py_environment
from tf_agents.environments import utils
from tf_agents.specs import array_spec
from tf_agents.environments import wrappers
from tf_agents.environments import suite_gym
from tf_agents.trajectories import time_step as ts

tf.random.set_seed(12)
tf.config.list_physical_devices('GPU') 


error:
     ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-66358c3aa169> in <module>()
      7 import numpy as np
      8 
----> 9 from tf_agents.environments import py_environment
     10 from tf_agents.environments import tf_environment
     11 from tf_agents.environments import tf_py_environment

10 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
    546                 'in a future version' if date is None else ('after %s' % date),
    547                 instructions)
--> 548       return func(*args, **kwargs)
    549 
    550     doc = _add_deprecated_arg_notice_to_docstring(

TypeError: function() got an unexpected keyword argument 'reduce_retracing'

I cant understand what the problem is. When i try to import tfagent it throws this error

'function() got an unexpected keyword argument 'reduce_retracing'

in google colab.

I reinstalled all the packages and still the its giving me the same error.


Solution

  • You can simply upgrade to 2.9 version to resolve this issue. Attached gist for reference.