def testExportMultipleFunctions(self): export_decorator1 = tf_export.tf_export('nameA', 'nameB') export_decorator2 = tf_export.tf_export('nameC', 'nameD') decorated_function1 = export_decorator1(_test_function) decorated_function2 = export_decorator2(_test_function2) self.assertEquals(decorated_function1, _test_function) self.assertEquals(decorated_function2, _test_function2) self.assertEquals(('nameA', 'nameB'), decorated_function1._tf_api_names) self.assertEquals(('nameC', 'nameD'), decorated_function2._tf_api_names)
def setUp(self): # Add fake op to a module that has 'tensorflow' in the name. sys.modules[_MODULE_NAME] = imp.new_module(_MODULE_NAME) setattr(sys.modules[_MODULE_NAME], 'test_op', test_op) setattr(sys.modules[_MODULE_NAME], 'TestClass', TestClass) test_op.__module__ = _MODULE_NAME TestClass.__module__ = _MODULE_NAME tf_export('consts._TEST_CONSTANT').export_constant( _MODULE_NAME, '_TEST_CONSTANT')
def testExportClasses(self): export_decorator_a = tf_export.tf_export('TestClassA1') export_decorator_a(TestClassA) self.assertEquals(('TestClassA1',), TestClassA._tf_api_names) self.assertTrue('_tf_api_names' not in TestClassB.__dict__) export_decorator_b = tf_export.tf_export('TestClassB1') export_decorator_b(TestClassB) self.assertEquals(('TestClassA1',), TestClassA._tf_api_names) self.assertEquals(('TestClassB1',), TestClassB._tf_api_names)
def testRaisesExceptionIfInvalidSymbolName(self): # TensorFlow code is not allowed to export symbols under package # tf.estimator with self.assertRaises(tf_export.InvalidSymbolNameError): tf_export.tf_export('estimator.invalid') # All symbols exported by Estimator must be under tf.estimator package. with self.assertRaises(tf_export.InvalidSymbolNameError): tf_export.estimator_export('invalid') with self.assertRaises(tf_export.InvalidSymbolNameError): tf_export.estimator_export('Estimator.invalid') with self.assertRaises(tf_export.InvalidSymbolNameError): tf_export.estimator_export('invalid.estimator')
def testExportSingleConstant(self): module1 = self._CreateMockModule('module1') export_decorator = tf_export.tf_export('NAME_A', 'NAME_B') export_decorator.export_constant('module1', 'test_constant') self.assertEquals([(('NAME_A', 'NAME_B'), 'test_constant')], module1._tf_api_constants)
def testExportSingleFunction(self): export_decorator = tf_export.tf_export('nameA', 'nameB') decorated_function = export_decorator(_test_function) self.assertEquals(decorated_function, _test_function) self.assertEquals(('nameA', 'nameB'), decorated_function._tf_api_names) self.assertEquals(['nameA', 'nameB'], tf_export.get_v1_names(decorated_function)) self.assertEquals(['nameA', 'nameB'], tf_export.get_v2_names(decorated_function))
def testOverridesFunction(self): _test_function2._tf_api_names = ['abc'] export_decorator = tf_export.tf_export( 'nameA', 'nameB', overrides=[_test_function2]) export_decorator(_test_function) # _test_function overrides _test_function2. So, _tf_api_names # should be removed from _test_function2. self.assertFalse(hasattr(_test_function2, '_tf_api_names'))
def testExportMultipleConstants(self): module1 = self._CreateMockModule('module1') module2 = self._CreateMockModule('module2') test_constant1 = 123 test_constant2 = 'abc' test_constant3 = 0.5 export_decorator1 = tf_export.tf_export('NAME_A', 'NAME_B') export_decorator2 = tf_export.tf_export('NAME_C', 'NAME_D') export_decorator3 = tf_export.tf_export('NAME_E', 'NAME_F') export_decorator1.export_constant('module1', test_constant1) export_decorator2.export_constant('module2', test_constant2) export_decorator3.export_constant('module2', test_constant3) self.assertEquals([(('NAME_A', 'NAME_B'), 123)], module1._tf_api_constants) self.assertEquals([(('NAME_C', 'NAME_D'), 'abc'), (('NAME_E', 'NAME_F'), 0.5)], module2._tf_api_constants)
def testMultipleDecorators(self): def get_wrapper(func): def wrapper(*unused_args, **unused_kwargs): pass return tf_decorator.make_decorator(func, wrapper) decorated_function = get_wrapper(_test_function) export_decorator = tf_export.tf_export('nameA', 'nameB') exported_function = export_decorator(decorated_function) self.assertEquals(decorated_function, exported_function) self.assertEquals(('nameA', 'nameB'), _test_function._tf_api_names)
def testExportClassInEstimator(self): export_decorator_a = tf_export.tf_export('TestClassA1') export_decorator_a(TestClassA) self.assertEquals(('TestClassA1',), TestClassA._tf_api_names) export_decorator_b = tf_export.estimator_export( 'estimator.TestClassB1') export_decorator_b(TestClassB) self.assertTrue('_tf_api_names' not in TestClassB.__dict__) self.assertEquals(('TestClassA1',), TestClassA._tf_api_names) self.assertEquals(['TestClassA1'], tf_export.get_v1_names(TestClassA)) self.assertEquals(['estimator.TestClassB1'], tf_export.get_v1_names(TestClassB))
from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_linalg_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import special_math_ops from tensorflow.python.util.tf_export import tf_export # Linear algebra ops. band_part = array_ops.matrix_band_part cholesky = linalg_ops.cholesky cholesky_solve = linalg_ops.cholesky_solve det = linalg_ops.matrix_determinant slogdet = gen_linalg_ops.log_matrix_determinant tf_export('linalg.slogdet')(slogdet) diag = array_ops.matrix_diag diag_part = array_ops.matrix_diag_part eigh = linalg_ops.self_adjoint_eig eigvalsh = linalg_ops.self_adjoint_eigvals einsum = special_math_ops.einsum expm = gen_linalg_ops.matrix_exponential tf_export('linalg.expm')(expm) eye = linalg_ops.eye inv = linalg_ops.matrix_inverse logm = gen_linalg_ops.matrix_logarithm tf_export('linalg.logm')(logm) lstsq = linalg_ops.matrix_solve_ls norm = linalg_ops.norm qr = linalg_ops.qr set_diag = array_ops.matrix_set_diag
from tensorflow.python.framework.test_util import is_gpu_available from tensorflow.python.ops.gradient_checker import compute_gradient_error from tensorflow.python.ops.gradient_checker import compute_gradient # pylint: enable=unused-import,g-bad-import-order import functools import sys from tensorflow.python.util.tf_export import tf_export if sys.version_info.major == 2: import mock # pylint: disable=g-import-not-at-top,unused-import else: from unittest import mock # pylint: disable=g-import-not-at-top,g-importing-member tf_export(v1=['test.mock'])(mock) # Import Benchmark class Benchmark = _googletest.Benchmark # pylint: disable=invalid-name # Import StubOutForTesting class StubOutForTesting = _googletest.StubOutForTesting # pylint: disable=invalid-name @tf_export('test.main') def main(argv=None): """Runs all unit tests.""" _test_util.InstallStackTraceHandler() return _googletest.main(argv)
name) _result = _RaggedRangeOutput._make(_result) return _result def RaggedRange(starts, limits, deltas, Tsplits=_dtypes.int64, name=None): return ragged_range(starts=starts, limits=limits, deltas=deltas, Tsplits=Tsplits, name=name) RaggedRange.__doc__ = ragged_range.__doc__ RaggedRange = _doc_controls.do_not_generate_docs(_kwarg_only(RaggedRange)) tf_export("raw_ops.RaggedRange")(RaggedRange) def ragged_range_eager_fallback(starts, limits, deltas, Tsplits=_dtypes.int64, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function ragged_range """ _ctx = ctx if ctx else _context.context() if Tsplits is None: Tsplits = _dtypes.int64 Tsplits = _execute.make_type(Tsplits, "Tsplits")
eye_separation=eye_separation, mu=mu, normalize=normalize, normalize_max=normalize_max, normalize_min=normalize_min, border_level=border_level, number_colors=number_colors, output_image_shape=output_image_shape, output_data_window=output_data_window, name=name) SingleImageRandomDotStereograms.__doc__ = single_image_random_dot_stereograms.__doc__ SingleImageRandomDotStereograms = _doc_controls.do_not_generate_docs( _kwarg_only(SingleImageRandomDotStereograms)) tf_export("raw_ops.SingleImageRandomDotStereograms")( SingleImageRandomDotStereograms) def single_image_random_dot_stereograms_eager_fallback( depth_values, hidden_surface_removal=True, convergence_dots_size=8, dots_per_inch=72, eye_separation=2.5, mu=0.3333, normalize=True, normalize_max=-100, normalize_min=100, border_level=0, number_colors=256, output_image_shape=[1024, 768, 1],
raise _result = _op.outputs[:] _inputs_flat = _op.inputs _attrs = ("T", _op.get_attr("T")) _execute.record_gradient("Resampler", _inputs_flat, _attrs, _result, name) _result, = _result return _result def Resampler(data, warp, name=None): return resampler(data=data, warp=warp, name=name) Resampler.__doc__ = resampler.__doc__ Resampler = _doc_controls.do_not_generate_docs(_kwarg_only(Resampler)) tf_export("raw_ops.Resampler")(Resampler) def resampler_eager_fallback(data, warp, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function resampler """ _ctx = ctx if ctx else _context.context() _attr_T, _inputs_T = _execute.args_to_matching_eager([data, warp], _ctx) (data, warp) = _inputs_T _inputs_flat = [data, warp] _attrs = ("T", _attr_T) _result = _execute.execute(b"Resampler", 1, inputs=_inputs_flat, attrs=_attrs,
_op._get_attr_bool("hashed_output"), "num_buckets", _op._get_attr_int("num_buckets"), "hash_key", _op._get_attr_int("hash_key"), "ragged_values_types", _op.get_attr("ragged_values_types"), "ragged_splits_types", _op.get_attr("ragged_splits_types"), "sparse_values_types", _op.get_attr("sparse_values_types"), "dense_types", _op.get_attr("dense_types"), "out_values_type", _op._get_attr_type("out_values_type"), "out_row_splits_type", _op._get_attr_type("out_row_splits_type")) _inputs_flat = _op.inputs _execute.record_gradient("RaggedCross", _inputs_flat, _attrs, _result) _result = _RaggedCrossOutput._make(_result) return _result RaggedCross = tf_export("raw_ops.RaggedCross")(_ops.to_raw_op(ragged_cross)) def ragged_cross_eager_fallback(ragged_values, ragged_row_splits, sparse_indices, sparse_values, sparse_shape, dense_inputs, input_order, hashed_output, num_buckets, hash_key, out_values_type, out_row_splits_type, name, ctx): if not isinstance(sparse_indices, (list, tuple)): raise TypeError("Expected list for 'sparse_indices' argument to " "'ragged_cross' Op, not %r." % sparse_indices) _attr_Nsparse = len(sparse_indices) if not isinstance(sparse_shape, (list, tuple)): raise TypeError("Expected list for 'sparse_shape' argument to " "'ragged_cross' Op, not %r." % sparse_shape) if len(sparse_shape) != _attr_Nsparse:
np.bool8: (False, True), np.uint8: (0, 255), np.uint16: (0, 65535), np.int8: (-128, 127), np.int16: (-32768, 32767), np.int64: (-2**63, 2**63 - 1), np.uint64: (0, 2**64 - 1), np.int32: (-2**31, 2**31 - 1), np.uint32: (0, 2**32 - 1), np.float32: (-1, 1), np.float64: (-1, 1) } # Define standard wrappers for the types_pb2.DataType enum. resource = DType(types_pb2.DT_RESOURCE) tf_export("resource").export_constant(__name__, "resource") variant = DType(types_pb2.DT_VARIANT) tf_export("variant").export_constant(__name__, "variant") float16 = DType(types_pb2.DT_HALF) tf_export("float16").export_constant(__name__, "float16") half = float16 tf_export("half").export_constant(__name__, "half") float32 = DType(types_pb2.DT_FLOAT) tf_export("float32").export_constant(__name__, "float32") float64 = DType(types_pb2.DT_DOUBLE) tf_export("float64").export_constant(__name__, "float64") double = float64 tf_export("double").export_constant(__name__, "double") int32 = DType(types_pb2.DT_INT32) tf_export("int32").export_constant(__name__, "int32") uint8 = DType(types_pb2.DT_UINT8)
Returns: A `SparseTensorValue` object. """ indices, values, dense_shape = _eval_using_default_session( [self.indices, self.values, self.dense_shape], feed_dict, self.graph, session) return SparseTensorValue(indices, values, dense_shape) @staticmethod def _override_operator(operator, func): _override_helper(SparseTensor, operator, func) SparseTensorValue = collections.namedtuple( "SparseTensorValue", ["indices", "values", "dense_shape"]) tf_export("SparseTensorValue")(SparseTensorValue) pywrap_tensorflow.RegisterType("SparseTensorValue", SparseTensorValue) @tf_export("convert_to_tensor_or_sparse_tensor") def convert_to_tensor_or_sparse_tensor(value, dtype=None, name=None): """Converts value to a `SparseTensor` or `Tensor`. Args: value: A `SparseTensor`, `SparseTensorValue`, or an object whose type has a registered `Tensor` conversion function. dtype: Optional element type for the returned tensor. If missing, the type is inferred from the type of `value`. name: Optional name to use if a new `Tensor` is created. Returns:
np.bool8: (False, True), np.uint8: (0, 255), np.uint16: (0, 65535), np.int8: (-128, 127), np.int16: (-32768, 32767), np.int64: (-2**63, 2**63 - 1), np.uint64: (0, 2**64 - 1), np.int32: (-2**31, 2**31 - 1), np.uint32: (0, 2**32 - 1), np.float32: (-1, 1), np.float64: (-1, 1) } # Define standard wrappers for the types_pb2.DataType enum. resource = DType(types_pb2.DT_RESOURCE) tf_export("dtypes.resource", "resource").export_constant(__name__, "resource") variant = DType(types_pb2.DT_VARIANT) tf_export("dtypes.variant", "variant").export_constant(__name__, "variant") float16 = DType(types_pb2.DT_HALF) tf_export("dtypes.float16", "float16").export_constant(__name__, "float16") half = float16 tf_export("dtypes.half", "half").export_constant(__name__, "half") float32 = DType(types_pb2.DT_FLOAT) tf_export("dtypes.float32", "float32").export_constant(__name__, "float32") float64 = DType(types_pb2.DT_DOUBLE) tf_export("dtypes.float64", "float64").export_constant(__name__, "float64") double = float64 tf_export("dtypes.double", "double").export_constant(__name__, "double") int32 = DType(types_pb2.DT_INT32) tf_export("dtypes.int32", "int32").export_constant(__name__, "int32") uint8 = DType(types_pb2.DT_UINT8)
return _result def GRUBlockCell(x, h_prev, w_ru, w_c, b_ru, b_c, name=None): return gru_block_cell(x=x, h_prev=h_prev, w_ru=w_ru, w_c=w_c, b_ru=b_ru, b_c=b_c, name=name) GRUBlockCell.__doc__ = gru_block_cell.__doc__ GRUBlockCell = _doc_controls.do_not_generate_docs(_kwarg_only(GRUBlockCell)) tf_export("raw_ops.GRUBlockCell")(GRUBlockCell) def gru_block_cell_eager_fallback(x, h_prev, w_ru, w_c, b_ru, b_c, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function gru_block_cell """ _ctx = ctx if ctx else _context.context() _attr_T, _inputs_T = _execute.args_to_matching_eager(
from tensorflow.python.framework import tensor_shape from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_linalg_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import special_math_ops from tensorflow.python.util.tf_export import tf_export # Linear algebra ops. band_part = array_ops.matrix_band_part cholesky = linalg_ops.cholesky cholesky_solve = linalg_ops.cholesky_solve det = linalg_ops.matrix_determinant slogdet = gen_linalg_ops.log_matrix_determinant tf_export('linalg.slogdet')(slogdet) diag = array_ops.matrix_diag diag_part = array_ops.matrix_diag_part eigh = linalg_ops.self_adjoint_eig eigvalsh = linalg_ops.self_adjoint_eigvals einsum = special_math_ops.einsum eye = linalg_ops.eye inv = linalg_ops.matrix_inverse logm = gen_linalg_ops.matrix_logarithm lu = gen_linalg_ops.lu tf_export('linalg.logm')(logm) lstsq = linalg_ops.matrix_solve_ls norm = linalg_ops.norm qr = linalg_ops.qr set_diag = array_ops.matrix_set_diag solve = linalg_ops.matrix_solve
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Utilities for preprocessing sequence data. """ # pylint: disable=invalid-name from __future__ import absolute_import from __future__ import division from __future__ import print_function from keras_preprocessing import sequence from tensorflow.python.util.tf_export import tf_export pad_sequences = sequence.pad_sequences make_sampling_table = sequence.make_sampling_table skipgrams = sequence.skipgrams # TODO(fchollet): consider making `_remove_long_seq` public. _remove_long_seq = sequence._remove_long_seq # pylint: disable=protected-access TimeseriesGenerator = sequence.TimeseriesGenerator tf_export('keras.preprocessing.sequence.pad_sequences')(pad_sequences) tf_export( 'keras.preprocessing.sequence.make_sampling_table')(make_sampling_table) tf_export('keras.preprocessing.sequence.skipgrams')(skipgrams) tf_export( 'keras.preprocessing.sequence.TimeseriesGenerator')(TimeseriesGenerator)
""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from keras_applications import imagenet_utils from tensorflow.python.util.tf_export import tf_export decode_predictions = imagenet_utils.decode_predictions preprocess_input = imagenet_utils.preprocess_input tf_export( 'keras.applications.imagenet_utils.decode_predictions', 'keras.applications.densenet.decode_predictions', 'keras.applications.inception_resnet_v2.decode_predictions', 'keras.applications.inception_v3.decode_predictions', 'keras.applications.mobilenet.decode_predictions', 'keras.applications.mobilenet_v2.decode_predictions', 'keras.applications.nasnet.decode_predictions', 'keras.applications.resnet50.decode_predictions', 'keras.applications.vgg16.decode_predictions', 'keras.applications.vgg19.decode_predictions', 'keras.applications.xception.decode_predictions', )(decode_predictions) tf_export( 'keras.applications.imagenet_utils.preprocess_input', 'keras.applications.resnet50.preprocess_input', 'keras.applications.vgg16.preprocess_input', 'keras.applications.vgg19.preprocess_input', )(preprocess_input)
stride=stride, magnitude_squared=magnitude_squared, name=name) _result = _outputs[:] if _execute.must_record_gradient(): _attrs = ("window_size", _op._get_attr_int("window_size"), "stride", _op._get_attr_int("stride"), "magnitude_squared", _op._get_attr_bool("magnitude_squared")) _inputs_flat = _op.inputs _execute.record_gradient("AudioSpectrogram", _inputs_flat, _attrs, _result) _result, = _result return _result AudioSpectrogram = tf_export("raw_ops.AudioSpectrogram")( _ops.to_raw_op(audio_spectrogram)) def audio_spectrogram_eager_fallback(input, window_size, stride, magnitude_squared, name, ctx): window_size = _execute.make_int(window_size, "window_size") stride = _execute.make_int(stride, "stride") if magnitude_squared is None: magnitude_squared = False magnitude_squared = _execute.make_bool(magnitude_squared, "magnitude_squared") input = _ops.convert_to_tensor(input, _dtypes.float32) _inputs_flat = [input] _attrs = ("window_size", window_size, "stride", stride, "magnitude_squared", magnitude_squared) _result = _execute.execute(b"AudioSpectrogram",
def testEAllowMultipleExports(self): _test_function._tf_api_names = ['name1', 'name2'] tf_export.tf_export('nameRed', 'nameBlue', allow_multiple_exports=True)( _test_function) self.assertEquals(['name1', 'name2', 'nameRed', 'nameBlue'], _test_function._tf_api_names)
_op._get_attr_int("max_enqueued_batches"), "batch_timeout_micros", _op._get_attr_int("batch_timeout_micros"), "allowed_batch_sizes", _op.get_attr("allowed_batch_sizes"), "grad_timeout_micros", _op._get_attr_int("grad_timeout_micros"), "container", _op.get_attr("container"), "shared_name", _op.get_attr("shared_name"), "batching_queue", _op.get_attr("batching_queue"), "T", _op.get_attr("T")) _inputs_flat = _op.inputs _execute.record_gradient( "Batch", _inputs_flat, _attrs, _result) _result = [_result[:len(in_tensors)]] + _result[len(in_tensors):] _result = _BatchOutput._make(_result) return _result Batch = tf_export("raw_ops.Batch")(_ops.to_raw_op(batch)) def batch_eager_fallback(in_tensors, num_batch_threads, max_batch_size, batch_timeout_micros, grad_timeout_micros, max_enqueued_batches, allowed_batch_sizes, container, shared_name, batching_queue, name, ctx): num_batch_threads = _execute.make_int(num_batch_threads, "num_batch_threads") max_batch_size = _execute.make_int(max_batch_size, "max_batch_size") batch_timeout_micros = _execute.make_int(batch_timeout_micros, "batch_timeout_micros") grad_timeout_micros = _execute.make_int(grad_timeout_micros, "grad_timeout_micros") if max_enqueued_batches is None: max_enqueued_batches = 10 max_enqueued_batches = _execute.make_int(max_enqueued_batches, "max_enqueued_batches") if allowed_batch_sizes is None: allowed_batch_sizes = [] if not isinstance(allowed_batch_sizes, (list, tuple)): raise TypeError( "Expected list for 'allowed_batch_sizes' argument to "
name=None): return sparse_feature_cross(indices=indices, values=values, shapes=shapes, dense=dense, hashed_output=hashed_output, num_buckets=num_buckets, out_type=out_type, internal_type=internal_type, name=name) SparseFeatureCross.__doc__ = sparse_feature_cross.__doc__ SparseFeatureCross = _doc_controls.do_not_generate_docs( _kwarg_only(SparseFeatureCross)) tf_export("raw_ops.SparseFeatureCross")(SparseFeatureCross) def sparse_feature_cross_eager_fallback(indices, values, shapes, dense, hashed_output, num_buckets, out_type, internal_type, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function sparse_feature_cross """
"TensorShape([r]), got %r" % shape) rank = tensor_shape.dimension_value(shape[0]) return [ tensor_shape.TensorShape([None, rank]), # indices tensor_shape.TensorShape([None]), # values tensor_shape.TensorShape([rank]) # dense_shape ] @property def _is_graph_tensor(self): return hasattr(self._values, "graph") SparseTensorValue = collections.namedtuple( "SparseTensorValue", ["indices", "values", "dense_shape"]) tf_export(v1=["SparseTensorValue"])(SparseTensorValue) pywrap_tensorflow.RegisterType("SparseTensorValue", SparseTensorValue) @tf_export(v1=["convert_to_tensor_or_sparse_tensor"]) def convert_to_tensor_or_sparse_tensor(value, dtype=None, name=None): """Converts value to a `SparseTensor` or `Tensor`. Args: value: A `SparseTensor`, `SparseTensorValue`, or an object whose type has a registered `Tensor` conversion function. dtype: Optional element type for the returned tensor. If missing, the type is inferred from the type of `value`. name: Optional name to use if a new `Tensor` is created. Returns:
"ClusterDef", "Example", # from example_pb2 "Feature", # from example_pb2 "Features", # from example_pb2 "FeatureList", # from example_pb2 "FeatureLists", # from example_pb2 "FloatList", # from example_pb2. "Int64List", # from example_pb2. "JobDef", "SaverDef", # From saver_pb2. "SequenceExample", # from example_pb2. "ServerDef", ] # pylint: disable=undefined-variable tf_export("train.BytesList")(BytesList) tf_export("train.ClusterDef")(ClusterDef) tf_export("train.Example")(Example) tf_export("train.Feature")(Feature) tf_export("train.Features")(Features) tf_export("train.FeatureList")(FeatureList) tf_export("train.FeatureLists")(FeatureLists) tf_export("train.FloatList")(FloatList) tf_export("train.Int64List")(Int64List) tf_export("train.JobDef")(JobDef) tf_export("train.SaverDef")(SaverDef) tf_export("train.SequenceExample")(SequenceExample) tf_export("train.ServerDef")(ServerDef) # pylint: enable=undefined-variable # Include extra modules for docstrings because:
"[elided %d identical lines from previous traceback]\n" % (elide_count - 1, ), last_elided_line ]) is_eliding = False output.extend(line) # pylint: disable=protected-access original_op = original_op._original_op # pylint: enable=protected-access return "".join(output) else: return self.message OK = error_codes_pb2.OK tf_export("errors.OK").export_constant(__name__, "OK") CANCELLED = error_codes_pb2.CANCELLED tf_export("errors.CANCELLED").export_constant(__name__, "CANCELLED") UNKNOWN = error_codes_pb2.UNKNOWN tf_export("errors.UNKNOWN").export_constant(__name__, "UNKNOWN") INVALID_ARGUMENT = error_codes_pb2.INVALID_ARGUMENT tf_export("errors.INVALID_ARGUMENT").export_constant(__name__, "INVALID_ARGUMENT") DEADLINE_EXCEEDED = error_codes_pb2.DEADLINE_EXCEEDED tf_export("errors.DEADLINE_EXCEEDED").export_constant(__name__, "DEADLINE_EXCEEDED") NOT_FOUND = error_codes_pb2.NOT_FOUND tf_export("errors.NOT_FOUND").export_constant(__name__, "NOT_FOUND") ALREADY_EXISTS = error_codes_pb2.ALREADY_EXISTS tf_export("errors.ALREADY_EXISTS").export_constant(__name__, "ALREADY_EXISTS") PERMISSION_DENIED = error_codes_pb2.PERMISSION_DENIED
from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python import pywrap_tensorflow from tensorflow.python.util.tf_export import tf_export __version__ = pywrap_tensorflow.__version__ __git_version__ = pywrap_tensorflow.__git_version__ __compiler_version__ = pywrap_tensorflow.__compiler_version__ __cxx11_abi_flag__ = pywrap_tensorflow.__cxx11_abi_flag__ __monolithic_build__ = pywrap_tensorflow.__monolithic_build__ VERSION = __version__ tf_export("VERSION").export_constant(__name__, "VERSION") GIT_VERSION = __git_version__ tf_export("GIT_VERSION").export_constant(__name__, "GIT_VERSION") COMPILER_VERSION = __compiler_version__ tf_export("COMPILER_VERSION").export_constant(__name__, "COMPILER_VERSION") CXX11_ABI_FLAG = __cxx11_abi_flag__ MONOLITHIC_BUILD = __monolithic_build__ GRAPH_DEF_VERSION = pywrap_tensorflow.GRAPH_DEF_VERSION tf_export("GRAPH_DEF_VERSION").export_constant(__name__, "GRAPH_DEF_VERSION") GRAPH_DEF_VERSION_MIN_CONSUMER = ( pywrap_tensorflow.GRAPH_DEF_VERSION_MIN_CONSUMER) tf_export("GRAPH_DEF_VERSION_MIN_CONSUMER").export_constant( __name__, "GRAPH_DEF_VERSION_MIN_CONSUMER") GRAPH_DEF_VERSION_MIN_PRODUCER = ( pywrap_tensorflow.GRAPH_DEF_VERSION_MIN_PRODUCER)
_allowed_symbols = [ 'DEBUG', 'ERROR', 'FATAL', 'INFO', 'TaskLevelStatusMessage', 'WARN', 'debug', 'error', 'fatal', 'flush', 'get_verbosity', 'info', 'log', 'log_if', 'log_every_n', 'log_first_n', 'set_verbosity', 'vlog', 'warn', 'warning', ] tf_export('logging.DEBUG').export_constant(__name__, 'DEBUG') tf_export('logging.ERROR').export_constant(__name__, 'ERROR') tf_export('logging.FATAL').export_constant(__name__, 'FATAL') tf_export('logging.INFO').export_constant(__name__, 'INFO') tf_export('logging.WARN').export_constant(__name__, 'WARN') remove_undocumented(__name__, _allowed_symbols)
# XLA JIT compiler APIs. from tensorflow.python.compiler.xla import jit from tensorflow.python.compiler.xla import xla # Required due to `rnn` and `rnn_cell` not being imported in `nn` directly # (due to a circular dependency issue: rnn depends on layers). nn.dynamic_rnn = rnn.dynamic_rnn nn.static_rnn = rnn.static_rnn nn.raw_rnn = rnn.raw_rnn nn.bidirectional_dynamic_rnn = rnn.bidirectional_dynamic_rnn nn.static_state_saving_rnn = rnn.static_state_saving_rnn nn.rnn_cell = rnn_cell # Export protos # pylint: disable=undefined-variable tf_export(v1=['AttrValue'])(AttrValue) tf_export(v1=['ConfigProto'])(ConfigProto) tf_export(v1=['Event', 'summary.Event'])(Event) tf_export(v1=['GPUOptions'])(GPUOptions) tf_export(v1=['GraphDef'])(GraphDef) tf_export(v1=['GraphOptions'])(GraphOptions) tf_export(v1=['HistogramProto'])(HistogramProto) tf_export(v1=['LogMessage'])(LogMessage) tf_export(v1=['MetaGraphDef'])(MetaGraphDef) tf_export(v1=['NameAttrList'])(NameAttrList) tf_export(v1=['NodeDef'])(NodeDef) tf_export(v1=['OptimizerOptions'])(OptimizerOptions) tf_export(v1=['RunMetadata'])(RunMetadata) tf_export(v1=['RunOptions'])(RunOptions) tf_export(v1=['SessionLog', 'summary.SessionLog'])(SessionLog) tf_export(v1=['Summary', 'summary.Summary'])(Summary)
from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python import pywrap_tensorflow from tensorflow.python.util.tf_export import tf_export __version__ = pywrap_tensorflow.__version__ __git_version__ = pywrap_tensorflow.__git_version__ __compiler_version__ = pywrap_tensorflow.__compiler_version__ __cxx11_abi_flag__ = pywrap_tensorflow.__cxx11_abi_flag__ __monolithic_build__ = pywrap_tensorflow.__monolithic_build__ VERSION = __version__ tf_export("VERSION", "__version__").export_constant(__name__, "VERSION") GIT_VERSION = __git_version__ tf_export("GIT_VERSION", "__git_version__").export_constant( __name__, "GIT_VERSION") COMPILER_VERSION = __compiler_version__ tf_export("COMPILER_VERSION", "__compiler_version__").export_constant( __name__, "COMPILER_VERSION") CXX11_ABI_FLAG = __cxx11_abi_flag__ tf_export("CXX11_ABI_FLAG", "__cxx11_abi_flag__").export_constant( __name__, "CXX11_ABI_FLAG") MONOLITHIC_BUILD = __monolithic_build__ tf_export("MONOLITHIC_BUILD", "__monolithic_build__").export_constant( __name__, "MONOLITHIC_BUILD") GRAPH_DEF_VERSION = pywrap_tensorflow.GRAPH_DEF_VERSION tf_export("GRAPH_DEF_VERSION").export_constant(__name__, "GRAPH_DEF_VERSION")
protocol="", fail_fast=True, timeout_in_ms=0, name=None): return rpc(address=address, method=method, request=request, protocol=protocol, fail_fast=fail_fast, timeout_in_ms=timeout_in_ms, name=name) Rpc.__doc__ = rpc.__doc__ Rpc = _doc_controls.do_not_generate_docs(_kwarg_only(Rpc)) tf_export("raw_ops.Rpc")(Rpc) def rpc_eager_fallback(address, method, request, protocol="", fail_fast=True, timeout_in_ms=0, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function rpc """ _ctx = ctx if ctx else _context.context() if protocol is None:
new_vocab_offset, num_new_vocab, old_vocab_size=-1, name=None): return generate_vocab_remapping(new_vocab_file=new_vocab_file, old_vocab_file=old_vocab_file, new_vocab_offset=new_vocab_offset, num_new_vocab=num_new_vocab, old_vocab_size=old_vocab_size, name=name) GenerateVocabRemapping.__doc__ = generate_vocab_remapping.__doc__ GenerateVocabRemapping = _doc_controls.do_not_generate_docs( _kwarg_only(GenerateVocabRemapping)) tf_export("raw_ops.GenerateVocabRemapping")(GenerateVocabRemapping) def generate_vocab_remapping_eager_fallback(new_vocab_file, old_vocab_file, new_vocab_offset, num_new_vocab, old_vocab_size=-1, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function generate_vocab_remapping """ _ctx = ctx if ctx else _context.context() new_vocab_offset = _execute.make_int(new_vocab_offset, "new_vocab_offset") num_new_vocab = _execute.make_int(num_new_vocab, "num_new_vocab")
# ============================================================================== """Signature constants for SavedModel save and restore operations. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.util.tf_export import tf_export # Key in the signature def map for `default` serving signatures. The default # signature is used in inference requests where a specific signature was not # specified. DEFAULT_SERVING_SIGNATURE_DEF_KEY = "serving_default" tf_export("saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY" ).export_constant(__name__, "DEFAULT_SERVING_SIGNATURE_DEF_KEY") ################################################################################ # Classification API constants. # Classification inputs. CLASSIFY_INPUTS = "inputs" tf_export("saved_model.signature_constants.CLASSIFY_INPUTS").export_constant( __name__, "CLASSIFY_INPUTS") # Classification method name used in a SignatureDef. CLASSIFY_METHOD_NAME = "tensorflow/serving/classify" tf_export( "saved_model.signature_constants.CLASSIFY_METHOD_NAME").export_constant( __name__, "CLASSIFY_METHOD_NAME")
values, field_names, message_type, descriptor_source="local://", name=None): return encode_proto(sizes=sizes, values=values, field_names=field_names, message_type=message_type, descriptor_source=descriptor_source, name=name) EncodeProto.__doc__ = encode_proto.__doc__ EncodeProto = _doc_controls.do_not_generate_docs(_kwarg_only(EncodeProto)) tf_export("raw_ops.EncodeProto")(EncodeProto) def encode_proto_eager_fallback(sizes, values, field_names, message_type, descriptor_source="local://", name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function encode_proto """ _ctx = ctx if ctx else _context.context() if not isinstance(field_names, (list, tuple)): raise TypeError("Expected list for 'field_names' argument to "
'LogMessage', 'MetaGraphDef', 'NameAttrList', 'NodeDef', 'OptimizerOptions', 'RunOptions', 'RunMetadata', 'SessionLog', 'Summary', 'SummaryMetadata', 'TensorInfo', # Used for tf.saved_model functionality. ] # Export protos # pylint: disable=undefined-variable tf_export('AttrValue')(AttrValue) tf_export('ConfigProto')(ConfigProto) tf_export('Event', 'summary.Event')(Event) tf_export('GPUOptions')(GPUOptions) tf_export('GraphDef')(GraphDef) tf_export('GraphOptions')(GraphOptions) tf_export('HistogramProto')(HistogramProto) tf_export('LogMessage')(LogMessage) tf_export('MetaGraphDef')(MetaGraphDef) tf_export('NameAttrList')(NameAttrList) tf_export('NodeDef')(NodeDef) tf_export('OptimizerOptions')(OptimizerOptions) tf_export('RunMetadata')(RunMetadata) tf_export('RunOptions')(RunOptions) tf_export('SessionLog', 'summary.SessionLog')(SessionLog) tf_export('Summary', 'summary.Summary')(Summary)
instances, equality checks if two instances' id() values are equal. Args: other: Object to compare against. Returns: `self is other`. """ return self is other # Fully reparameterized distribution: samples from a fully # reparameterized distribution support straight-through gradients with # respect to all parameters. FULLY_REPARAMETERIZED = ReparameterizationType("FULLY_REPARAMETERIZED") tf_export(v1=["distributions.FULLY_REPARAMETERIZED"]).export_constant( __name__, "FULLY_REPARAMETERIZED") # Not reparameterized distribution: samples from a non- # reparameterized distribution do not support straight-through gradients for # at least some of the parameters. NOT_REPARAMETERIZED = ReparameterizationType("NOT_REPARAMETERIZED") tf_export(v1=["distributions.NOT_REPARAMETERIZED"]).export_constant( __name__, "NOT_REPARAMETERIZED") @six.add_metaclass(_DistributionMeta) @tf_export(v1=["distributions.Distribution"]) class Distribution(_BaseDistribution): """A generic probability distribution base class. `Distribution` is a base class for constructing and organizing properties
from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python import pywrap_tensorflow from tensorflow.python.util.tf_export import tf_export __version__ = pywrap_tensorflow.__version__ __git_version__ = pywrap_tensorflow.__git_version__ __compiler_version__ = pywrap_tensorflow.__compiler_version__ __cxx11_abi_flag__ = pywrap_tensorflow.__cxx11_abi_flag__ __monolithic_build__ = pywrap_tensorflow.__monolithic_build__ VERSION = __version__ tf_export("VERSION", "__version__").export_constant(__name__, "VERSION") GIT_VERSION = __git_version__ tf_export("GIT_VERSION").export_constant(__name__, "GIT_VERSION") COMPILER_VERSION = __compiler_version__ tf_export("COMPILER_VERSION").export_constant(__name__, "COMPILER_VERSION") CXX11_ABI_FLAG = __cxx11_abi_flag__ tf_export("CXX11_ABI_FLAG").export_constant(__name__, "CXX11_ABI_FLAG") MONOLITHIC_BUILD = __monolithic_build__ tf_export("MONOLITHIC_BUILD").export_constant(__name__, "MONOLITHIC_BUILD") GRAPH_DEF_VERSION = pywrap_tensorflow.GRAPH_DEF_VERSION tf_export("GRAPH_DEF_VERSION").export_constant(__name__, "GRAPH_DEF_VERSION") GRAPH_DEF_VERSION_MIN_CONSUMER = ( pywrap_tensorflow.GRAPH_DEF_VERSION_MIN_CONSUMER) tf_export("GRAPH_DEF_VERSION_MIN_CONSUMER").export_constant( __name__, "GRAPH_DEF_VERSION_MIN_CONSUMER")
_inputs_flat = _op.inputs _attrs = None _execute.record_gradient("KMC2ChainInitialization", _inputs_flat, _attrs, _result, name) _result, = _result return _result def KMC2ChainInitialization(distances, seed, name=None): return kmc2_chain_initialization(distances=distances, seed=seed, name=name) KMC2ChainInitialization.__doc__ = kmc2_chain_initialization.__doc__ KMC2ChainInitialization = _doc_controls.do_not_generate_docs( _kwarg_only(KMC2ChainInitialization)) tf_export("raw_ops.KMC2ChainInitialization")(KMC2ChainInitialization) def kmc2_chain_initialization_eager_fallback(distances, seed, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function kmc2_chain_initialization """ _ctx = ctx if ctx else _context.context() distances = _ops.convert_to_tensor(distances, _dtypes.float32) seed = _ops.convert_to_tensor(seed, _dtypes.int64) _inputs_flat = [distances, seed] _attrs = None _result = _execute.execute(b"KMC2ChainInitialization",
def testRaisesExceptionIfAlreadyHasAPINames(self): _test_function._tf_api_names = ['abc'] export_decorator = tf_export.tf_export('nameA', 'nameB') with self.assertRaises(tf_export.SymbolAlreadyExposedError): export_decorator(_test_function)
_attrs = ("Tvalues", _op._get_attr_type("Tvalues"), "Tindices", _op._get_attr_type("Tindices"), "Tsplits", _op._get_attr_type("Tsplits"), "PARAMS_RAGGED_RANK", _op.get_attr("PARAMS_RAGGED_RANK"), "OUTPUT_RAGGED_RANK", _op.get_attr("OUTPUT_RAGGED_RANK")) _execute.record_gradient( "RaggedGather", _inputs_flat, _attrs, _result, name) _result = [_result[:OUTPUT_RAGGED_RANK]] + _result[OUTPUT_RAGGED_RANK:] _result = _RaggedGatherOutput._make(_result) return _result def RaggedGather(params_nested_splits, params_dense_values, indices, OUTPUT_RAGGED_RANK, name=None): return ragged_gather(params_nested_splits=params_nested_splits, params_dense_values=params_dense_values, indices=indices, OUTPUT_RAGGED_RANK=OUTPUT_RAGGED_RANK, name=name) RaggedGather.__doc__ = ragged_gather.__doc__ RaggedGather = _doc_controls.do_not_generate_docs(_kwarg_only(RaggedGather)) tf_export("raw_ops.RaggedGather")(RaggedGather) def ragged_gather_eager_fallback(params_nested_splits, params_dense_values, indices, OUTPUT_RAGGED_RANK, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function ragged_gather """ _ctx = ctx if ctx else _context.context() if not isinstance(params_nested_splits, (list, tuple)): raise TypeError( "Expected list for 'params_nested_splits' argument to " "'ragged_gather' Op, not %r." % params_nested_splits) _attr_PARAMS_RAGGED_RANK = len(params_nested_splits) OUTPUT_RAGGED_RANK = _execute.make_int(OUTPUT_RAGGED_RANK, "OUTPUT_RAGGED_RANK") _attr_Tvalues, (params_dense_values,) = _execute.args_to_matching_eager([params_dense_values], _ctx) _attr_Tindices, (indices,) = _execute.args_to_matching_eager([indices], _ctx)
# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== # pylint: disable=invalid-name """Inception V3 model for Keras. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from keras_applications import inception_v3 from tensorflow.python.util.tf_export import tf_export InceptionV3 = inception_v3.InceptionV3 decode_predictions = inception_v3.decode_predictions preprocess_input = inception_v3.preprocess_input tf_export('keras.applications.inception_v3.InceptionV3', 'keras.applications.InceptionV3')(InceptionV3) tf_export('keras.applications.inception_v3.preprocess_input')(preprocess_input)
# ============================================================================== """Experimental API for optimizing `tf.data` pipelines.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.ops import gen_experimental_dataset_ops from tensorflow.python.util.tf_export import tf_export # A constant that can be used to enable auto-tuning. AUTOTUNE = -1 tf_export("data.experimental.AUTOTUNE").export_constant(__name__, "AUTOTUNE") # TODO(jsimsa): Support RE matching for both individual transformation (e.g. to # account for indexing) and transformation sequence. def assert_next(transformations): """A transformation that asserts which transformations happen next. Args: transformations: A `tf.string` vector `tf.Tensor` identifying the transformations that are expected to happen next. Returns: A `Dataset` transformation function, which can be passed to `tf.data.Dataset.apply`. """
input=input, shift=shift, axis=axis, name=name) _result = _outputs[:] if _execute.must_record_gradient(): _attrs = ("T", _op._get_attr_type("T"), "Tshift", _op._get_attr_type("Tshift"), "Taxis", _op._get_attr_type("Taxis")) _inputs_flat = _op.inputs _execute.record_gradient("Roll", _inputs_flat, _attrs, _result) _result, = _result return _result Roll = tf_export("raw_ops.Roll")(_ops.to_raw_op(roll)) def roll_eager_fallback(input, shift, axis, name, ctx): _attr_T, (input, ) = _execute.args_to_matching_eager([input], ctx) _attr_Tshift, (shift, ) = _execute.args_to_matching_eager([shift], ctx) _attr_Taxis, (axis, ) = _execute.args_to_matching_eager([axis], ctx) _inputs_flat = [input, shift, axis] _attrs = ("T", _attr_T, "Tshift", _attr_Tshift, "Taxis", _attr_Taxis) _result = _execute.execute(b"Roll", 1, inputs=_inputs_flat, attrs=_attrs, ctx=ctx, name=name) if _execute.must_record_gradient():
# ============================================================================== """Common tags used for graphs in SavedModel. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.util.tf_export import tf_export # Tag for the `serving` graph. SERVING = "serve" tf_export( "saved_model.SERVING", v1=["saved_model.SERVING", "saved_model.tag_constants.SERVING"]).export_constant( __name__, "SERVING") # Tag for the `training` graph. TRAINING = "train" tf_export( "saved_model.TRANING", v1=["saved_model.TRAINING", "saved_model.tag_constants.TRAINING"]).export_constant( __name__, "TRAINING") # Tag for the `eval` graph. Not exported while the export logic is in contrib. EVAL = "eval" # Tag for the `gpu` graph.
"RaggedTensorToSparse", rt_nested_splits=rt_nested_splits, rt_dense_values=rt_dense_values, name=name) _result = _op.outputs[:] _inputs_flat = _op.inputs _attrs = ("RAGGED_RANK", _op.get_attr("RAGGED_RANK"), "T", _op.get_attr("T")) _execute.record_gradient( "RaggedTensorToSparse", _inputs_flat, _attrs, _result, name) _result = _RaggedTensorToSparseOutput._make(_result) return _result @_doc_controls.do_not_generate_docs @_kwarg_only def RaggedTensorToSparse(rt_nested_splits, rt_dense_values): return ragged_tensor_to_sparse(rt_nested_splits=rt_nested_splits, rt_dense_values=rt_dense_values) tf_export("raw_ops.RaggedTensorToSparse")(RaggedTensorToSparse) def ragged_tensor_to_sparse_eager_fallback(rt_nested_splits, rt_dense_values, name=None, ctx=None): r"""This is the slowpath function for Eager mode. This is for function ragged_tensor_to_sparse """ _ctx = ctx if ctx else _context.context() if not isinstance(rt_nested_splits, (list, tuple)): raise TypeError( "Expected list for 'rt_nested_splits' argument to " "'ragged_tensor_to_sparse' Op, not %r." % rt_nested_splits) _attr_RAGGED_RANK = len(rt_nested_splits) _attr_T, (rt_dense_values,) = _execute.args_to_matching_eager([rt_dense_values], _ctx) rt_nested_splits = _ops.convert_n_to_tensor(rt_nested_splits, _dtypes.int64) _inputs_flat = list(rt_nested_splits) + [rt_dense_values]
name=name) except (TypeError, ValueError): result = _dispatch.dispatch(bitwise_and, x=x, y=y, name=name) if result is not _dispatch.OpDispatcher.NOT_SUPPORTED: return result raise _result = _outputs[:] if _execute.must_record_gradient(): _attrs = ("T", _op._get_attr_type("T")) _inputs_flat = _op.inputs _execute.record_gradient("BitwiseAnd", _inputs_flat, _attrs, _result) _result, = _result return _result BitwiseAnd = tf_export("raw_ops.BitwiseAnd")(_ops.to_raw_op(bitwise_and)) def bitwise_and_eager_fallback(x, y, name, ctx): _attr_T, _inputs_T = _execute.args_to_matching_eager([x, y], ctx) (x, y) = _inputs_T _inputs_flat = [x, y] _attrs = ("T", _attr_T) _result = _execute.execute(b"BitwiseAnd", 1, inputs=_inputs_flat, attrs=_attrs, ctx=ctx, name=name) if _execute.must_record_gradient(): _execute.record_gradient("BitwiseAnd", _inputs_flat, _attrs, _result)
from tensorflow.python.keras import activations from tensorflow.python.keras import applications from tensorflow.python.keras import backend from tensorflow.python.keras import callbacks from tensorflow.python.keras import constraints from tensorflow.python.keras import datasets from tensorflow.python.keras import estimator from tensorflow.python.keras import initializers from tensorflow.python.keras import layers from tensorflow.python.keras import losses from tensorflow.python.keras import metrics from tensorflow.python.keras import models from tensorflow.python.keras import optimizers from tensorflow.python.keras import preprocessing from tensorflow.python.keras import regularizers from tensorflow.python.keras import utils from tensorflow.python.keras import wrappers from tensorflow.python.keras.layers import Input from tensorflow.python.keras.models import Model from tensorflow.python.keras.models import Sequential from tensorflow.python.util.tf_export import tf_export __version__ = '2.2.4-tf' tf_export('keras.__version__').export_constant(__name__, '__version__') del absolute_import del division del print_function
name=name) _result = _outputs[:] if _execute.must_record_gradient(): _attrs = ("tensor_type", _op._get_attr_type("tensor_type"), "tensor_name", _op.get_attr("tensor_name"), "send_device", _op.get_attr("send_device"), "send_device_incarnation", _op._get_attr_int("send_device_incarnation"), "recv_device", _op.get_attr("recv_device"), "client_terminated", _op._get_attr_bool("client_terminated")) _inputs_flat = _op.inputs _execute.record_gradient("Recv", _inputs_flat, _attrs, _result) _result, = _result return _result Recv = tf_export("raw_ops.Recv")(_ops.to_raw_op(recv)) def recv_eager_fallback(tensor_type, tensor_name, send_device, send_device_incarnation, recv_device, client_terminated, name, ctx): tensor_type = _execute.make_type(tensor_type, "tensor_type") tensor_name = _execute.make_str(tensor_name, "tensor_name") send_device = _execute.make_str(send_device, "send_device") send_device_incarnation = _execute.make_int(send_device_incarnation, "send_device_incarnation") recv_device = _execute.make_str(recv_device, "recv_device") if client_terminated is None: client_terminated = False client_terminated = _execute.make_bool(client_terminated, "client_terminated")
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Constants for SavedModel save and restore operations. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.util.tf_export import tf_export # Subdirectory name containing the asset files. ASSETS_DIRECTORY = "assets" tf_export("saved_model.constants.ASSETS_DIRECTORY").export_constant( __name__, "ASSETS_DIRECTORY") # CollectionDef key containing SavedModel assets. ASSETS_KEY = "saved_model_assets" tf_export("saved_model.constants.ASSETS_KEY").export_constant( __name__, "ASSETS_KEY") # CollectionDef key for the legacy init op. LEGACY_INIT_OP_KEY = "legacy_init_op" tf_export("saved_model.constants.LEGACY_INIT_OP_KEY").export_constant( __name__, "LEGACY_INIT_OP_KEY") # CollectionDef key for the SavedModel main op. MAIN_OP_KEY = "saved_model_main_op" tf_export("saved_model.constants.MAIN_OP_KEY").export_constant( __name__, "MAIN_OP_KEY")
# Validate encoding, a LookupError will be raised if invalid. encoding = codecs.lookup(encoding).name if isinstance(bytes_or_text, _six.text_type): return bytes_or_text elif isinstance(bytes_or_text, bytes): return bytes_or_text.decode(encoding) else: raise TypeError('Expected binary or unicode string, got %r' % bytes_or_text) def as_str(bytes_or_text, encoding='utf-8'): return as_text(bytes_or_text, encoding) tf_export('compat.as_text')(as_text) tf_export('compat.as_bytes')(as_bytes) tf_export('compat.as_str')(as_str) @tf_export('compat.as_str_any') def as_str_any(value, encoding='utf-8'): """Converts input to `str` type. Uses `str(value)`, except for `bytes` typed inputs, which are converted using `as_str`. Args: value: A object that can be converted to `str`. encoding: Encoding for `bytes` typed inputs.
instances, equality checks if two instances' id() values are equal. Args: other: Object to compare against. Returns: `self is other`. """ return self is other # Fully reparameterized distribution: samples from a fully # reparameterized distribution support straight-through gradients with # respect to all parameters. FULLY_REPARAMETERIZED = ReparameterizationType("FULLY_REPARAMETERIZED") tf_export("distributions.FULLY_REPARAMETERIZED").export_constant( __name__, "FULLY_REPARAMETERIZED") # Not reparameterized distribution: samples from a non- # reparameterized distribution do not support straight-through gradients for # at least some of the parameters. NOT_REPARAMETERIZED = ReparameterizationType("NOT_REPARAMETERIZED") tf_export("distributions.NOT_REPARAMETERIZED").export_constant( __name__, "NOT_REPARAMETERIZED") @six.add_metaclass(_DistributionMeta) @tf_export("distributions.Distribution") class Distribution(_BaseDistribution): """A generic probability distribution base class.
import numpy as np from tensorflow.python.data.ops import dataset_ops from tensorflow.python.data.ops.options import ExternalStatePolicy from tensorflow.python.data.util import nest from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape from tensorflow.python.framework import tensor_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_experimental_dataset_ops as ged_ops from tensorflow.python.util.tf_export import tf_export SHARD_HINT = -1 tf_export("data.experimental.SHARD_HINT").export_constant( __name__, "SHARD_HINT") class _AutoShardDataset(dataset_ops.UnaryDataset): """A `Dataset` that shards the `Dataset` automatically. This dataset takes in an existing dataset and tries to automatically figure out how to shard the dataset in a multi-worker scenario using graph rewrites. If the AutoShardPolicy is set to FILE, it walks up the dataset graph until it finds a reader dataset, then inserts a ShardDataset op before that node so that each worker only sees some files. If the AutoShardPolicy is set to DATA, it inserts a ShardDataset op at the end of the input pipeline, before any terminal PrefetchDataset if there is one. Additionally, if there is a RebatchDatasetV2 in the input pipeline, it
from tensorflow.python.framework.test_util import TensorFlowTestCase as TestCase from tensorflow.python.framework.test_util import gpu_device_name from tensorflow.python.framework.test_util import is_gpu_available from tensorflow.python.ops.gradient_checker import compute_gradient_error from tensorflow.python.ops.gradient_checker import compute_gradient # pylint: enable=unused-import,g-bad-import-order import sys from tensorflow.python.util.tf_export import tf_export if sys.version_info.major == 2: import mock # pylint: disable=g-import-not-at-top,unused-import else: from unittest import mock # pylint: disable=g-import-not-at-top tf_export('test.mock')(mock) # Import Benchmark class Benchmark = _googletest.Benchmark # pylint: disable=invalid-name # Import StubOutForTesting class StubOutForTesting = _googletest.StubOutForTesting # pylint: disable=invalid-name @tf_export('test.main') def main(argv=None): """Runs all unit tests.""" _test_util.InstallStackTraceHandler() return _googletest.main(argv)
# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== # pylint: disable=invalid-name """Xception V1 model for Keras. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from keras_applications import xception from tensorflow.python.util.tf_export import tf_export Xception = xception.Xception decode_predictions = xception.decode_predictions preprocess_input = xception.preprocess_input tf_export('keras.applications.xception.Xception', 'keras.applications.Xception')(Xception) tf_export('keras.applications.xception.preprocess_input')(preprocess_input)