Create a version of frozen keras in TF.

This will be serving as dependency for other legacy TF high level API
like tf.layers and feature column etc.

This change also removes the mixed precision API, which v1 API shouldn't rely on. We might remove more features from the layer in follow up cls, eg distribution strategy, etc. This will help reduce the scope of python code that will be copied.

PiperOrigin-RevId: 299201999
Change-Id: Idd5bc851fcb76116b5b66cfb8dddab6e8087b3e0
This commit is contained in:
Scott Zhu 2020-03-05 14:58:50 -08:00 committed by TensorFlower Gardener
parent c216cfa871
commit a1d2f94d2e
5 changed files with 4183 additions and 0 deletions

View File

@ -0,0 +1,15 @@
# DO NOT USE
Everything under this package is for internal usage, and only serves a
dependency from legacy TF v1 APIs that relies on Keras. Any active development
should happen in third_party/tensorflow/python/keras instead.
## Background
In order to build a more modular Tensorflow and Keras, we decided to split the
Keras code into its own repository. Having TensorFlow depend on
Keras is a red flag as it is a reverse dependency. As some legacy TF V1 APIs
are using Keras classes as base classes, like `Layer`, we decided to keep a copy
of the trimmed Keras code to resolve the reverse dependency. This will also
ensure the stability of the TF V1 API will be not affected by the active
development of the Keras project.

View File

@ -0,0 +1,73 @@
load("//tensorflow:tensorflow.bzl", "tf_py_test")
package(
default_visibility = ["//tensorflow:__subpackages__"],
licenses = ["notice"], # Apache 2.0
)
py_library(
name = "legacy_base_layer",
srcs = ["legacy_base_layer.py"],
deps = [
"//tensorflow/core:protos_all_py",
"//tensorflow/python:array_ops",
"//tensorflow/python:auto_control_deps",
"//tensorflow/python:constant_op",
"//tensorflow/python:dtypes",
"//tensorflow/python:errors",
"//tensorflow/python:framework_ops",
"//tensorflow/python:func_graph",
"//tensorflow/python:math_ops",
"//tensorflow/python:resource_variable_ops",
"//tensorflow/python:tensor_spec",
"//tensorflow/python:tensor_util",
"//tensorflow/python:util",
"//tensorflow/python:variables",
"//tensorflow/python/autograph/core",
"//tensorflow/python/autograph/impl",
"//tensorflow/python/distribute:distribute_lib",
"//tensorflow/python/eager:context",
"//tensorflow/python/eager:execute",
"//tensorflow/python/eager:function",
"//tensorflow/python/keras:backend",
"//tensorflow/python/keras:constraints",
"//tensorflow/python/keras:initializers",
"//tensorflow/python/keras:metrics",
"//tensorflow/python/keras:regularizers",
"//tensorflow/python/keras/engine",
"//tensorflow/python/keras/engine:base_layer_utils",
"//tensorflow/python/keras/engine:input_spec",
"//tensorflow/python/keras/saving",
"//tensorflow/python/keras/utils:generic_utils",
"//tensorflow/python/keras/utils:layer_utils",
"//tensorflow/python/keras/utils:tf_utils",
"//tensorflow/python/module",
"//tensorflow/python/ops/ragged:ragged_tensor",
"//tensorflow/python/training/tracking",
"//tensorflow/python/training/tracking:base",
"//tensorflow/python/training/tracking:data_structures",
"//tensorflow/python/training/tracking:layer_utils",
"//tensorflow/tools/docs:doc_controls",
"//third_party/py/numpy",
"@six_archive//:six",
],
)
tf_py_test(
name = "legacy_base_layer_test",
size = "medium",
srcs = ["legacy_base_layer_test.py"],
python_version = "PY3",
shard_count = 8,
tags = [
"no_rocm",
"nomac", # TODO(mihaimaruseac): b/127695564
],
deps = [
":legacy_base_layer",
"//tensorflow/python:client_testlib",
"//tensorflow/python/keras",
"//third_party/py/numpy",
"@absl_py//absl/testing:parameterized",
],
)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -113,6 +113,7 @@ COMMON_PIP_DEPS = [
"//tensorflow/python/distribute:combinations",
"//tensorflow/python/distribute:multi_process_runner",
"//tensorflow/python/eager:eager_pip",
"//tensorflow/python/frozen_keras/engine:legacy_base_layer",
"//tensorflow/python/keras:combinations",
"//tensorflow/python/keras/layers/preprocessing:preprocessing_test_utils",
"//tensorflow/python/keras/distribute:distribute_strategy_test_lib",