Search code examples
tensorflowgoogle-colaboratorytensorflow-datasetstensorflow-federatedfederated-learning

Error while executing federated learning text generation tutorial in Colab


I am trying to follow this tutorial on federated learning TensorFlow and when executing this line I get an error:

train_data, test_data = tff.simulation.datasets.shakespeare.load_data()

The error:

    Downloading shakespeare.sqlite.lzma:  79%|███████▉  | 1048576/1329828 [00:00<00:00, 12187174.26it/s]
---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
<ipython-input-12-f8f1fc62c096> in <module>()
----> 1 train_data, test_data = tff.simulation.datasets.shakespeare.load_data()

4 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/lib/io/file_io.py in _prewrite_check(self)
     86                                            "File isn't open for writing")
     87       self._writable_file = _pywrap_file_io.WritableFile(
---> 88           compat.path_to_bytes(self.__name), compat.as_bytes(self.__mode))
     89 
     90   def _prepare_value(self, val):

NotFoundError: /root/.tff/shakespeare.sqlite; No such file or directory

enter image description here


Solution

  • This is a problem with the current tensorflow-federated-nightly pip package. It should be fixed by https://github.com/tensorflow/federated/pull/1162.

    In the mean time, try changing the pip install in the first cell to use the tensorflow-federated package instead of the nightly package. Example:

    !pip install --quiet --upgrade tensorflow_federated
    !pip install --quiet --upgrade nest_asyncio
    
    import nest_asyncio
    nest_asyncio.apply()