Skip to content

import tensorflow_datasets always enables eager execution #52

@gongliyu

Description

@gongliyu

It seems importing tensorflow_datasets always enables eager execution, which I don't want. Is there a way to disable it? Thank you very much!

If I execute the following piece, the eager mode will be enabled by importing tensorflow_datasets

In [1]: import tensorflow as tf

In [2]: import tensorflow_datasets as tfds

In [3]: tf.executing_eagerly()
Out[3]: True

However, if I execute the following, an error will be raised!

In [1]: import tensorflow as tf

In [2]: tf.executing_eagerly()
Out[2]: False

In [3]: import tensorflow_datasets as tfds
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-46a8a2031c9c> in <module>
----> 1 import tensorflow_datasets as tfds

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow_datasets\__init__.py in <module>
     49 # Imports for registration
     50 # pylint: disable=g-import-not-at-top
---> 51 from tensorflow_datasets import audio
     52 from tensorflow_datasets import image
     53 from tensorflow_datasets import text

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow_datasets\audio\__init__.py in <module>
     16 """Audio datasets."""
     17
---> 18 from tensorflow_datasets.audio.librispeech import Librispeech
     19 from tensorflow_datasets.audio.librispeech import LibrispeechConfig
     20 from tensorflow_datasets.audio.nsynth import Nsynth

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow_datasets\audio\librispeech.py in <module>
     26
     27 from tensorflow_datasets.core import api_utils
---> 28 import tensorflow_datasets.public_api as tfds
     29
     30 _CITATION = """\

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow_datasets\public_api.py in <module>
     61
     62
---> 63 testing = _import_testing()

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow_datasets\public_api.py in _import_testing()
     55 def _import_testing():
     56   try:
---> 57     from tensorflow_datasets import testing  # pylint: disable=redefined-outer-name
     58     return testing
     59   except:

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow_datasets\testing\__init__.py in <module>
     16 """Testing utilities."""
     17
---> 18 from tensorflow_datasets.testing.dataset_builder_testing import DatasetBuilderTestCase
     19 from tensorflow_datasets.testing.test_case import TestCase
     20 from tensorflow_datasets.testing.test_utils import DummyDatasetSharedGenerator

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow_datasets\testing\dataset_builder_testing.py in <module>
     37 from tensorflow_datasets.testing import test_utils
     38
---> 39 tf.compat.v1.enable_eager_execution()
     40
     41 # `os` module Functions for which tf.io.gfile equivalent should be preferred.

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in enable_eager_execution(config, device_policy, execution_mode)
   5421         device_policy=device_policy,
   5422         execution_mode=execution_mode,
-> 5423         server_def=None)
   5424
   5425

C:\Users\Liyu\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in enable_eager_execution_internal(config, device_policy, execution_mode, server_def)
   5489   else:
   5490     raise ValueError(
-> 5491         "tf.enable_eager_execution must be called at program startup.")
   5492
   5493   # Monkey patch to get rid of an unnecessary conditional since the context is

ValueError: tf.enable_eager_execution must be called at program startup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions