def testCompatV1APIInstrumenting(self): self.assertFalse( module_wrapper.TFModuleWrapper.compat_v1_usage_recorded) apis = {'cosh': ('', 'cmd')} mock_tf = MockModule('tensorflow') mock_tf_wrapped = module_wrapper.TFModuleWrapper(mock_tf, 'test', public_apis=apis) mock_tf_wrapped.cosh # pylint: disable=pointless-statement self.assertFalse( module_wrapper.TFModuleWrapper.compat_v1_usage_recorded) mock_tf_v1 = MockModule('tensorflow.compat.v1') mock_tf_v1_wrapped = module_wrapper.TFModuleWrapper(mock_tf_v1, 'test', public_apis=apis) self.assertFalse( module_wrapper.TFModuleWrapper.compat_v1_usage_recorded) mock_tf_v1_wrapped.cosh # pylint: disable=pointless-statement self.assertTrue( module_wrapper.TFModuleWrapper.compat_v1_usage_recorded) # 'Reset' the status before testing against 'tensorflow.compat.v2.compat.v1' module_wrapper.TFModuleWrapper.compat_v1_usage_recorded = False mock_tf_v2_v1 = mock_tf_v1 = MockModule( 'tensorflow.compat.v2.compat.v1') mock_tf_v2_v1_wrapped = module_wrapper.TFModuleWrapper( mock_tf_v2_v1, 'test', public_apis=apis) self.assertFalse( module_wrapper.TFModuleWrapper.compat_v1_usage_recorded) mock_tf_v2_v1_wrapped.cosh # pylint: disable=pointless-statement self.assertTrue( module_wrapper.TFModuleWrapper.compat_v1_usage_recorded)
def testLazyLoadCorrectLiteModule(self): # If set, always load lite module from public API list. module = MockModule('test') apis = {'lite': ('', 'cmd')} module.lite = 5 import cmd as _cmd # pylint: disable=g-import-not-at-top wrapped_module = module_wrapper.TFModuleWrapper( module, 'test', public_apis=apis, deprecation=False, has_lite=True) self.assertEqual(wrapped_module.lite, _cmd)
def testLazyLoad(self): module = MockModule('test') apis = {'cmd': ('', 'cmd'), 'ABCMeta': ('abc', 'ABCMeta')} wrapped_module = module_wrapper.TFModuleWrapper( module, 'test', public_apis=apis, deprecation=False) import cmd as _cmd # pylint: disable=g-import-not-at-top from abc import ABCMeta as _ABCMeta # pylint: disable=g-import-not-at-top, g-importing-member self.assertEqual(wrapped_module.cmd, _cmd) self.assertEqual(wrapped_module.ABCMeta, _ABCMeta)
def testLazyLoadWildcardImport(self): # Test that public APIs are in __all__. module = MockModule('test') module._should_not_be_public = 5 apis = {'cmd': ('', 'cmd')} wrapped_module = module_wrapper.TFModuleWrapper( module, 'test', public_apis=apis, deprecation=False) setattr(wrapped_module, 'hello', 1) self.assertIn('hello', wrapped_module.__all__) self.assertIn('cmd', wrapped_module.__all__) self.assertNotIn('_should_not_be_public', wrapped_module.__all__)
def testLazyLoadLocalOverride(self): # Test that we can override and add fields to the wrapped module. module = MockModule('test') apis = {'cmd': ('', 'cmd')} wrapped_module = module_wrapper.TFModuleWrapper( module, 'test', public_apis=apis, deprecation=False) import cmd as _cmd # pylint: disable=g-import-not-at-top self.assertEqual(wrapped_module.cmd, _cmd) setattr(wrapped_module, 'cmd', 1) setattr(wrapped_module, 'cgi', 2) self.assertEqual(wrapped_module.cmd, 1) # override self.assertEqual(wrapped_module.cgi, 2) # add
def testLazyLoad(self): module = MockModule('test') apis = {'cmd': ('', 'cmd'), 'ABCMeta': ('abc', 'ABCMeta')} wrapped_module = module_wrapper.TFModuleWrapper( module, 'test', public_apis=apis, deprecation=False) import cmd as _cmd # pylint: disable=g-import-not-at-top from abc import ABCMeta as _ABCMeta # pylint: disable=g-import-not-at-top, g-importing-member self.assertFalse(wrapped_module._fastdict_key_in('cmd')) self.assertEqual(wrapped_module.cmd, _cmd) # Verify that the APIs are added to the cache of FastModuleType object self.assertTrue(wrapped_module._fastdict_key_in('cmd')) self.assertFalse(wrapped_module._fastdict_key_in('ABCMeta')) self.assertEqual(wrapped_module.ABCMeta, _ABCMeta) self.assertTrue(wrapped_module._fastdict_key_in('ABCMeta'))
def _clone_module(m): """Shallow clone of module `m`.""" if isinstance(m, _module_wrapper.TFModuleWrapper): # pylint: disable=protected-access return _module_wrapper.TFModuleWrapper( wrapped=_clone_module(m._tfmw_wrapped_module), module_name=m._tfmw_module_name, public_apis=m._tfmw_public_apis, deprecation=m._tfmw_print_deprecation_warnings, has_lite=m._tfmw_has_lite) # pylint: enable=protected-access out = type(m)(m.__name__, m.__doc__) out.__dict__.update(m.__dict__) return out
def testLazyLoadDict(self): # Test that we can override and add fields to the wrapped module. module = MockModule('test') apis = {'cmd': ('', 'cmd')} wrapped_module = module_wrapper.TFModuleWrapper( module, 'test', public_apis=apis, deprecation=False) import cmd as _cmd # pylint: disable=g-import-not-at-top # At first cmd key does not exist in __dict__ self.assertNotIn('cmd', wrapped_module.__dict__) # After it is referred (lazyloaded), it gets added to __dict__ wrapped_module.cmd # pylint: disable=pointless-statement self.assertEqual(wrapped_module.__dict__['cmd'], _cmd) # When we call setattr, it also gets added to __dict__ setattr(wrapped_module, 'cmd2', _cmd) self.assertEqual(wrapped_module.__dict__['cmd2'], _cmd)
def testLazyLoadLocalOverride(self): # Test that we can override and add fields to the wrapped module. module = MockModule('test') apis = {'cmd': ('', 'cmd')} wrapped_module = module_wrapper.TFModuleWrapper( module, 'test', public_apis=apis, deprecation=False) import cmd as _cmd # pylint: disable=g-import-not-at-top self.assertEqual(wrapped_module.cmd, _cmd) setattr(wrapped_module, 'cmd', 1) setattr(wrapped_module, 'cgi', 2) self.assertEqual(wrapped_module.cmd, 1) # override # Verify that the values are also updated in the cache # of the FastModuleType object self.assertEqual(wrapped_module._fastdict_get('cmd'), 1) self.assertEqual(wrapped_module.cgi, 2) # add self.assertEqual(wrapped_module._fastdict_get('cgi'), 2)
def testDeprecationWarnings(self, mock_warning): module = MockModule('test') module.foo = 1 module.bar = 2 module.baz = 3 all_renames_v2.symbol_renames['tf.test.bar'] = 'tf.bar2' all_renames_v2.symbol_renames['tf.test.baz'] = 'tf.compat.v1.baz' wrapped_module = module_wrapper.TFModuleWrapper(module, 'test') self.assertTrue(tf_inspect.ismodule(wrapped_module)) self.assertEqual(0, mock_warning.call_count) bar = wrapped_module.bar self.assertEqual(1, mock_warning.call_count) foo = wrapped_module.foo self.assertEqual(1, mock_warning.call_count) baz = wrapped_module.baz # pylint: disable=unused-variable self.assertEqual(2, mock_warning.call_count) baz = wrapped_module.baz self.assertEqual(2, mock_warning.call_count) # Check that values stayed the same self.assertEqual(module.foo, foo) self.assertEqual(module.bar, bar)
from tensorflow.python.ops.check_ops import assert_near_v2 as assert_near from tensorflow.python.ops.check_ops import assert_negative_v2 as assert_negative from tensorflow.python.ops.check_ops import assert_non_negative_v2 as assert_non_negative from tensorflow.python.ops.check_ops import assert_non_positive_v2 as assert_non_positive from tensorflow.python.ops.check_ops import assert_none_equal_v2 as assert_none_equal from tensorflow.python.ops.check_ops import assert_positive_v2 as assert_positive from tensorflow.python.ops.check_ops import assert_proper_iterable from tensorflow.python.ops.check_ops import assert_rank_at_least_v2 as assert_rank_at_least from tensorflow.python.ops.check_ops import assert_rank_in_v2 as assert_rank_in from tensorflow.python.ops.check_ops import assert_rank_v2 as assert_rank from tensorflow.python.ops.check_ops import assert_same_float_dtype from tensorflow.python.ops.check_ops import assert_scalar_v2 as assert_scalar from tensorflow.python.ops.check_ops import assert_shapes_v2 as assert_shapes from tensorflow.python.ops.check_ops import assert_type_v2 as assert_type from tensorflow.python.ops.check_ops import is_numeric_tensor from tensorflow.python.ops.control_flow_ops import Assert from tensorflow.python.ops.gen_array_ops import check_numerics from tensorflow.python.ops.numerics import verify_tensor_all_finite_v2 as assert_all_finite del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "debugging", public_apis=None, deprecation=False, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """Utility methods to create simple input_fns. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow_estimator.python.estimator.inputs.numpy_io import numpy_input_fn from tensorflow_estimator.python.estimator.inputs.pandas_io import pandas_input_fn del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "estimator.inputs", public_apis=None, deprecation=True, has_lite=False)
def testWrapperIsAModule(self): module = MockModule('test') wrapped_module = module_wrapper.TFModuleWrapper(module, 'test') self.assertTrue(tf_inspect.ismodule(wrapped_module))
from tensorflow.python.keras.preprocessing.image import DirectoryIterator from tensorflow.python.keras.preprocessing.image import ImageDataGenerator from tensorflow.python.keras.preprocessing.image import Iterator from tensorflow.python.keras.preprocessing.image import NumpyArrayIterator from tensorflow.python.keras.preprocessing.image import apply_affine_transform from tensorflow.python.keras.preprocessing.image import apply_brightness_shift from tensorflow.python.keras.preprocessing.image import apply_channel_shift from tensorflow.python.keras.preprocessing.image import array_to_img from tensorflow.python.keras.preprocessing.image import img_to_array from tensorflow.python.keras.preprocessing.image import load_img from tensorflow.python.keras.preprocessing.image import random_brightness from tensorflow.python.keras.preprocessing.image import random_channel_shift from tensorflow.python.keras.preprocessing.image import random_rotation from tensorflow.python.keras.preprocessing.image import random_shear from tensorflow.python.keras.preprocessing.image import random_shift from tensorflow.python.keras.preprocessing.image import random_zoom from tensorflow.python.keras.preprocessing.image import save_img del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "keras.preprocessing.image", public_apis=None, deprecation=True, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """Resource management library. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.platform.resource_loader import get_data_files_path from tensorflow.python.platform.resource_loader import get_path_to_datafile from tensorflow.python.platform.resource_loader import get_root_dir_with_all_resources from tensorflow.python.platform.resource_loader import load_resource from tensorflow.python.platform.resource_loader import readahead_file_path del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "resource_loader", public_apis=None, deprecation=True, has_lite=False)
from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.keras.engine.base_preprocessing_layer import PreprocessingLayer from tensorflow.python.keras.layers.preprocessing.image_preprocessing import CenterCrop from tensorflow.python.keras.layers.preprocessing.image_preprocessing import RandomContrast from tensorflow.python.keras.layers.preprocessing.image_preprocessing import RandomCrop from tensorflow.python.keras.layers.preprocessing.image_preprocessing import RandomFlip from tensorflow.python.keras.layers.preprocessing.image_preprocessing import RandomHeight from tensorflow.python.keras.layers.preprocessing.image_preprocessing import RandomRotation from tensorflow.python.keras.layers.preprocessing.image_preprocessing import RandomTranslation from tensorflow.python.keras.layers.preprocessing.image_preprocessing import RandomWidth from tensorflow.python.keras.layers.preprocessing.image_preprocessing import RandomZoom from tensorflow.python.keras.layers.preprocessing.image_preprocessing import Rescaling from tensorflow.python.keras.layers.preprocessing.image_preprocessing import Resizing from tensorflow.python.keras.layers.preprocessing.normalization_v1 import Normalization from tensorflow.python.keras.layers.preprocessing.text_vectorization_v1 import TextVectorization del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "keras.layers.experimental.preprocessing", public_apis=None, deprecation=True, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """Public API for tf.random.experimental namespace. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.ops.stateful_random_ops import Generator from tensorflow.python.ops.stateful_random_ops import create_rng_state from tensorflow.python.ops.stateful_random_ops import get_global_generator from tensorflow.python.ops.stateful_random_ops import set_global_generator del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "random.experimental", public_apis=None, deprecation=True, has_lite=False)
""" from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.saved_model.signature_constants import CLASSIFY_INPUTS from tensorflow.python.saved_model.signature_constants import CLASSIFY_METHOD_NAME from tensorflow.python.saved_model.signature_constants import CLASSIFY_OUTPUT_CLASSES from tensorflow.python.saved_model.signature_constants import CLASSIFY_OUTPUT_SCORES from tensorflow.python.saved_model.signature_constants import DEFAULT_SERVING_SIGNATURE_DEF_KEY from tensorflow.python.saved_model.signature_constants import PREDICT_INPUTS from tensorflow.python.saved_model.signature_constants import PREDICT_METHOD_NAME from tensorflow.python.saved_model.signature_constants import PREDICT_OUTPUTS from tensorflow.python.saved_model.signature_constants import REGRESS_INPUTS from tensorflow.python.saved_model.signature_constants import REGRESS_METHOD_NAME from tensorflow.python.saved_model.signature_constants import REGRESS_OUTPUTS del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "saved_model.signature_constants", public_apis=None, deprecation=True, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """Utilities for ImageNet data preprocessing & prediction decoding. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.keras.applications.imagenet_utils import decode_predictions from tensorflow.python.keras.applications.imagenet_utils import preprocess_input del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "keras.applications.imagenet_utils", public_apis=None, deprecation=True, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """Public API for tf.config.threading namespace. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.framework.config import get_inter_op_parallelism_threads from tensorflow.python.framework.config import get_intra_op_parallelism_threads from tensorflow.python.framework.config import set_inter_op_parallelism_threads from tensorflow.python.framework.config import set_intra_op_parallelism_threads del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "compat.v2.config.threading", public_apis=None, deprecation=False, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """NASNet-A models for Keras. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.keras.applications import NASNetLarge from tensorflow.python.keras.applications import NASNetMobile from tensorflow.python.keras.applications.nasnet import decode_predictions from tensorflow.python.keras.applications.nasnet import preprocess_input del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "keras.applications.nasnet", public_apis=None, deprecation=False, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """Public API for tf.lookup.experimental namespace. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.ops.lookup_ops import DenseHashTable del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "compat.v2.lookup.experimental", public_apis=None, deprecation=False, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """MNIST handwritten digits dataset. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.keras.datasets.mnist import load_data del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "keras.datasets.mnist", public_apis=None, deprecation=False, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """Wrapper for using the Scikit-Learn API with Keras models. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.keras.wrappers.scikit_learn import KerasClassifier from tensorflow.python.keras.wrappers.scikit_learn import KerasRegressor del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "keras.wrappers.scikit_learn", public_apis=None, deprecation=False, has_lite=False)
# This file is MACHINE GENERATED! Do not edit. # Generated by: tensorflow/python/tools/api/generator/create_python_api.py script. """Public API for tf.quantization namespace. """ from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.ops.array_ops import quantize from tensorflow.python.ops.array_ops import quantize_and_dequantize from tensorflow.python.ops.gen_array_ops import dequantize from tensorflow.python.ops.gen_array_ops import fake_quant_with_min_max_args from tensorflow.python.ops.gen_array_ops import fake_quant_with_min_max_args_gradient from tensorflow.python.ops.gen_array_ops import fake_quant_with_min_max_vars from tensorflow.python.ops.gen_array_ops import fake_quant_with_min_max_vars_gradient from tensorflow.python.ops.gen_array_ops import fake_quant_with_min_max_vars_per_channel from tensorflow.python.ops.gen_array_ops import fake_quant_with_min_max_vars_per_channel_gradient from tensorflow.python.ops.gen_array_ops import quantized_concat del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "quantization", public_apis=None, deprecation=True, has_lite=False)
from __future__ import print_function as _print_function import sys as _sys from tensorflow.python.keras.constraints import Constraint from tensorflow.python.keras.constraints import MaxNorm from tensorflow.python.keras.constraints import MaxNorm as max_norm from tensorflow.python.keras.constraints import MinMaxNorm from tensorflow.python.keras.constraints import MinMaxNorm as min_max_norm from tensorflow.python.keras.constraints import NonNeg from tensorflow.python.keras.constraints import NonNeg as non_neg from tensorflow.python.keras.constraints import RadialConstraint from tensorflow.python.keras.constraints import RadialConstraint as radial_constraint from tensorflow.python.keras.constraints import UnitNorm from tensorflow.python.keras.constraints import UnitNorm as unit_norm from tensorflow.python.keras.constraints import deserialize from tensorflow.python.keras.constraints import get from tensorflow.python.keras.constraints import serialize del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "keras.constraints", public_apis=None, deprecation=False, has_lite=False)
from tensorflow.python.keras.layers.pooling import MaxPool2D from tensorflow.python.keras.layers.pooling import MaxPool2D as MaxPooling2D from tensorflow.python.keras.layers.pooling import MaxPool3D from tensorflow.python.keras.layers.pooling import MaxPool3D as MaxPooling3D from tensorflow.python.keras.layers.recurrent import AbstractRNNCell from tensorflow.python.keras.layers.recurrent import GRU from tensorflow.python.keras.layers.recurrent import GRUCell from tensorflow.python.keras.layers.recurrent import LSTM from tensorflow.python.keras.layers.recurrent import LSTMCell from tensorflow.python.keras.layers.recurrent import RNN from tensorflow.python.keras.layers.recurrent import SimpleRNN from tensorflow.python.keras.layers.recurrent import SimpleRNNCell from tensorflow.python.keras.layers.recurrent import StackedRNNCells from tensorflow.python.keras.layers.serialization import deserialize from tensorflow.python.keras.layers.serialization import serialize from tensorflow.python.keras.layers.wrappers import Bidirectional from tensorflow.python.keras.layers.wrappers import TimeDistributed from tensorflow.python.keras.layers.wrappers import Wrapper del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "keras.layers", public_apis=None, deprecation=True, has_lite=False)
def testInitCachesAttributes(self): module = MockModule('test') wrapped_module = module_wrapper.TFModuleWrapper(module, 'test') self.assertTrue(wrapped_module._fastdict_key_in('_fastdict_key_in')) self.assertTrue(wrapped_module._fastdict_key_in('_tfmw_module_name')) self.assertTrue(wrapped_module._fastdict_key_in('__all__'))
from tensorflow.python.ops.gen_string_ops import decode_base64 from tensorflow.python.ops.gen_string_ops import encode_base64 from tensorflow.python.ops.image_ops_impl import decode_image from tensorflow.python.ops.image_ops_impl import is_jpeg from tensorflow.python.ops.parsing_ops import FixedLenFeature from tensorflow.python.ops.parsing_ops import FixedLenSequenceFeature from tensorflow.python.ops.parsing_ops import SparseFeature from tensorflow.python.ops.parsing_ops import VarLenFeature from tensorflow.python.ops.parsing_ops import decode_csv from tensorflow.python.ops.parsing_ops import decode_raw_v1 as decode_raw from tensorflow.python.ops.parsing_ops import parse_example from tensorflow.python.ops.parsing_ops import parse_sequence_example from tensorflow.python.ops.parsing_ops import parse_single_example from tensorflow.python.ops.parsing_ops import parse_single_sequence_example from tensorflow.python.ops.sparse_ops import deserialize_many_sparse from tensorflow.python.ops.sparse_ops import serialize_many_sparse from tensorflow.python.ops.sparse_ops import serialize_sparse from tensorflow.python.training.input import match_filenames_once del _print_function from tensorflow.python.util import module_wrapper as _module_wrapper if not isinstance(_sys.modules[__name__], _module_wrapper.TFModuleWrapper): _sys.modules[__name__] = _module_wrapper.TFModuleWrapper( _sys.modules[__name__], "compat.v1.io", public_apis=None, deprecation=False, has_lite=False)
def testPickleSubmodule(self): name = PickleTest.__module__ # The current module is a submodule. module = module_wrapper.TFModuleWrapper(MockModule(name), name) restored = pickle.loads(pickle.dumps(module)) self.assertEqual(restored.__name__, name) self.assertIsNotNone(restored.PickleTest)