0

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

1 Answers1

1

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()
Zachary Garrett
  • 2,911
  • 15
  • 23
  • Thanks for the answer, it worked on Colab, but on my local machine I got this: AttributeError: module 'tensorflow_federated' has no attribute 'federated_computation' Is there anything I can check for? – user8421958 Feb 21 '21 at 18:16
  • This might be caused by a running `python` in a directory that contains a subdirectory called `tensorflow_federated`. This would conflict with Python's [Module Search Path](https://docs.python.org/3.6/tutorial/modules.html#the-module-search-path). If such a subdirectory exists, try renaming it or running the Python interpreter from another location. – Zachary Garrett Feb 22 '21 at 01:52