Exemplo n.º 1
0
_tf_api_dir = _os.path.dirname(_os.path.dirname(_API_MODULE.__file__))
_current_module = _sys.modules[__name__]

if not hasattr(_current_module, '__path__'):
    __path__ = [_tf_api_dir]
elif _tf_api_dir not in __path__:
    __path__.append(_tf_api_dir)

# Hook external TensorFlow modules.

# Import compat before trying to import summary from tensorboard, so that
# reexport_tf_summary can get compat from sys.modules
_current_module.compat.v2.compat.v1 = _current_module.compat.v1
try:
    from tensorboard.summary._tf import summary
    _current_module.__path__ = ([_module_util.get_parent_dir(summary)] +
                                _current_module.__path__)
    setattr(_current_module, "summary", summary)
except ImportError:
    _logging.warning(
        "Limited tf.summary API due to missing TensorBoard installation.")

try:
    from tensorflow_estimator.python.estimator.api._v2 import estimator
    _current_module.__path__ = ([_module_util.get_parent_dir(estimator)] +
                                _current_module.__path__)
    setattr(_current_module, "estimator", estimator)
except ImportError:
    pass

try:
import logging as _logging
import os as _os
import sys as _sys

from tensorflow.python.tools import module_util as _module_util

# pylint: disable=g-bad-import-order

# API IMPORTS PLACEHOLDER

# Hook external TensorFlow modules.
_current_module = _sys.modules[__name__]
try:
  from tensorboard.summary._tf import summary
  _current_module.__path__ = (
      [_module_util.get_parent_dir(summary)] + _current_module.__path__)
except ImportError:
  _logging.warning(
      "Limited tf.compat.v2.summary API due to missing TensorBoard "
      "installation.")

try:
  from tensorflow_estimator.python.estimator.api._v2 import estimator
  _current_module.__path__ = (
      [_module_util.get_parent_dir(estimator)] + _current_module.__path__)
except ImportError:
  pass

try:
  from tensorflow.python.keras.api._v2 import keras
  _current_module.__path__ = (
Exemplo n.º 3
0
# Hook external TensorFlow modules.
_current_module = _sys.modules[__name__]

# Lazy-load estimator.
_estimator_module = "tensorflow_estimator.python.estimator.api._v1.estimator"
estimator = _LazyLoader("estimator", globals(), _estimator_module)
_module_dir = _module_util.get_parent_dir_for_name(_estimator_module)
if _module_dir:
  _current_module.__path__ = [_module_dir] + _current_module.__path__
setattr(_current_module, "estimator", estimator)

try:
  from tensorflow.python.keras.api._v1 import keras
  _current_module.__path__ = (
      [_module_util.get_parent_dir(keras)] + _current_module.__path__)
  setattr(_current_module, "keras", keras)
except ImportError:
  pass

# Explicitly import lazy-loaded modules to support autocompletion.
# pylint: disable=g-import-not-at-top
if not _six.PY2:
  import typing as _typing
  if _typing.TYPE_CHECKING:
    from tensorflow_estimator.python.estimator.api._v1 import estimator
# pylint: enable=g-import-not-at-top


from tensorflow.python.platform import flags  # pylint: disable=g-import-not-at-top
_current_module.app.flags = flags  # pylint: disable=undefined-variable
Exemplo n.º 4
0
from __future__ import print_function as _print_function

import os as _os
import sys as _sys

from tensorflow.python.tools import module_util as _module_util

# pylint: disable=g-bad-import-order

# API IMPORTS PLACEHOLDER

# Hook external TensorFlow modules.
_current_module = _sys.modules[__name__]
try:
  from tensorflow_estimator.python.estimator.api._v1 import estimator
  _current_module.__path__ = (
      [_module_util.get_parent_dir(estimator)] + _current_module.__path__)
except ImportError:
  pass

try:
  from tensorflow.python.keras.api._v1 import keras
  _current_module.__path__ = (
      [_module_util.get_parent_dir(keras)] + _current_module.__path__)
except ImportError:
  pass


from tensorflow.python.platform import flags  # pylint: disable=g-import-not-at-top
app.flags = flags  # pylint: disable=undefined-variable
Exemplo n.º 5
0
import logging as _logging
import os as _os
import sys as _sys

from tensorflow.python.tools import module_util as _module_util

# pylint: disable=g-bad-import-order

# API IMPORTS PLACEHOLDER

# Hook external TensorFlow modules.
_current_module = _sys.modules[__name__]
try:
    from tensorboard.summary._tf import summary
    _current_module.__path__.append(_module_util.get_parent_dir(summary))
except ImportError:
    _logging.warning(
        "Limited tf.compat.v2.summary API due to missing TensorBoard "
        "installation.")

try:
    from tensorflow_estimator.python.estimator.api._v2 import estimator
    _current_module.__path__.append(_module_util.get_parent_dir(estimator))
except ImportError:
    pass

try:
    from tensorflow.python.keras.api._v2 import keras
    _current_module.__path__.append(_module_util.get_parent_dir(keras))
except ImportError:
        from tensorflow_estimator.python.estimator.api._v1 import estimator
# pylint: enable=g-import-not-at-top

from tensorflow.python.platform import flags  # pylint: disable=g-import-not-at-top
_current_module.app.flags = flags  # pylint: disable=undefined-variable
setattr(_current_module, "flags", flags)

# Add module aliases from Keras to TF.
# Some tf endpoints actually lives under Keras.
if hasattr(_current_module, "keras"):
    # It is possible that keras is a lazily loaded module, which might break when
    # actually trying to import it. Have a Try-Catch to make sure it doesn't break
    # when it doing some very initial loading, like tf.compat.v2, etc.
    try:
        _layer_package = "keras.api._v1.keras.__internal__.legacy.layers"
        layers = _LazyLoader("layers", globals(), _layer_package)
        _module_dir = _module_util.get_parent_dir(layers)
        if _module_dir:
            _current_module.__path__ = [_module_dir] + _current_module.__path__
        setattr(_current_module, "layers", layers)

        _legacy_rnn_package = "keras.api._v1.keras.__internal__.legacy.rnn_cell"
        legacy_rnn = _LazyLoader("legacy_rnn", globals(), _legacy_rnn_package)
        _module_dir = _module_util.get_parent_dir(legacy_rnn)
        if _module_dir:
            _current_module.nn.__path__ = [_module_dir
                                           ] + _current_module.nn.__path__
        _current_module.nn.rnn_cell = legacy_rnn
    except ImportError:
        pass
Exemplo n.º 7
0
_current_module = _sys.modules[__name__]

if not hasattr(_current_module, '__path__'):
  __path__ = [_tf_api_dir]
elif _tf_api_dir not in __path__:
  __path__.append(_tf_api_dir)

# Hook external TensorFlow modules.
# Import compat before trying to import summary from tensorboard, so that
# reexport_tf_summary can get compat from sys.modules. Only needed if using
# lazy loading.
_current_module.compat.v2  # pylint: disable=pointless-statement
try:
  from tensorboard.summary._tf import summary
  _current_module.__path__ = (
      [_module_util.get_parent_dir(summary)] + _current_module.__path__)
  setattr(_current_module, "summary", summary)
except ImportError:
  _logging.warning(
      "Limited tf.summary API due to missing TensorBoard installation.")

# Load tensorflow-io-gcs-filesystem if enabled
# pylint: disable=g-import-not-at-top
if (_os.getenv('TF_USE_MODULAR_FILESYSTEM', '0') == 'true' or
    _os.getenv('TF_USE_MODULAR_FILESYSTEM', '0') == '1'):
  import tensorflow_io_gcs_filesystem as _tensorflow_io_gcs_filesystem
# pylint: enable=g-import-not-at-top

# Lazy-load estimator.
_estimator_module = "tensorflow_estimator.python.estimator.api._v2.estimator"
estimator = _LazyLoader("estimator", globals(), _estimator_module)
Exemplo n.º 8
0
# The 'app' module will be imported as part of the placeholder section above.
_current_module.app.flags = flags  # pylint: disable=undefined-variable
setattr(_current_module, "flags", flags)

_major_api_version = 1

# Add module aliases from Keras to TF.
# Some tf endpoints actually lives under Keras.
if hasattr(_current_module, "keras"):
    # It is possible that keras is a lazily loaded module, which might break when
    # actually trying to import it. Have a Try-Catch to make sure it doesn't break
    # when it doing some very initial loading, like tf.compat.v2, etc.
    try:
        _layer_package = "keras.api._v1.keras.__internal__.legacy.layers"
        layers = _LazyLoader("layers", globals(), _layer_package)
        _module_dir = _module_util.get_parent_dir(layers)
        if _module_dir:
            _current_module.__path__ = [_module_dir] + _current_module.__path__
        setattr(_current_module, "layers", layers)

        _legacy_rnn_package = "keras.api._v1.keras.__internal__.legacy.rnn_cell"
        legacy_rnn = _LazyLoader("legacy_rnn", globals(), _legacy_rnn_package)
        _current_module.nn.rnn_cell = legacy_rnn
    except ImportError:
        pass

# Load all plugin libraries from site-packages/tensorflow-plugins if we are
# running under pip.
# TODO(gunan): Enable setting an environment variable to define arbitrary plugin
# directories.
# TODO(gunan): Find a better location for this code snippet.