Tensorflow federated-learning giving error in colab

Viewed 80

I am trying to run the Tensorflow federated tutorial on colab.

However, so far, the from tensorflow_federated import python as tff code is giving the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-3-af7e4c5121d6> in <module>()
      1 import tensorflow as tf
----> 2 from tensorflow_federated import python as tff

6 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_federated/python/common_libs/structure.py in <module>()
    263 
    264 def to_odict(struct: Struct,
--> 265              recursive: bool = False) -> collections.OrderedDict[str, Any]:
    266   """Returns `struct` as an `OrderedDict`, if possible.
    267 

TypeError: 'type' object is not subscriptable

Any suggestion would be greatly appreciated. Thanks for your time.

1 Answers

TFF's recent releases have been compatible only with Python 3.9 and later; Google Colab's hosted runtimes are still on Python 3.7.

Likely the quickest way to run these notebooks is to run your own local runtime using Python 3.9, and connect the notebooks there; instructions on doing this from Colab can be found here.

Related