Fix preprocessing layers signatures.

PiperOrigin-RevId: 342531890
Change-Id: I543fcf6057e03647bf64c7dae7252194f329a31c
This commit is contained in:
Francois Chollet 2020-11-15 13:28:43 -08:00 committed by TensorFlower Gardener
parent ce0d0a458c
commit fa25e04b1f
13 changed files with 28 additions and 24 deletions

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Keras categorical preprocessing layers."""
"""Keras category crossing preprocessing layers."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division

View File

@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Keras text CategoryEncoding preprocessing layer."""
"""Keras CategoryEncoding preprocessing layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@ -86,8 +87,7 @@ class CategoryEncoding(base_preprocessing_layer.CombinerPreprocessingLayer):
[0. , 0.2, 0.3, 0. ],
[0. , 0.2, 0. , 0.4]])>
Attributes:
Arguments:
max_tokens: The maximum size of the vocabulary for this layer. If None,
there is no cap on the size of the vocabulary.
output_mode: Specification for the output of the layer.

View File

@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Keras preprocessing layers."""
"""Keras discretization preprocessing layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Keras categorical preprocessing layers."""
"""Keras hashing preprocessing layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division

View File

@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Keras text vectorization preprocessing layer."""
"""Keras index lookup preprocessing layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@ -57,7 +58,7 @@ class IndexLookup(base_preprocessing_layer.CombinerPreprocessingLayer):
vocabulary size, the most frequent terms will be used to create the
vocabulary.
Attributes:
Arguments:
max_tokens: The maximum size of the vocabulary for this layer. If None,
there is no cap on the size of the vocabulary. Note that this vocabulary
includes the OOV and mask tokens, so the effective number of tokens is

View File

@ -13,6 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Keras string lookup preprocessing layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@ -39,7 +40,7 @@ class IntegerLookup(index_lookup.IndexLookup):
vocabulary size, the most frequent terms will be used to create the
vocabulary.
Attributes:
Arguments:
max_values: The maximum size of the vocabulary for this layer. If None,
there is no cap on the size of the vocabulary. Note that this vocabulary
includes the OOV and mask values, so the effective number of values is

View File

@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Keras preprocessing layers."""
"""Normalization preprocessing layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@ -59,7 +60,7 @@ class Normalization(base_preprocessing_layer.CombinerPreprocessingLayer):
as the layer's weights. `adapt` should be called before `fit`, `evaluate`,
or `predict`.
Attributes:
Arguments:
axis: Integer or tuple of integers, the axis or axes that should be
"kept". These axes are not be summed over when calculating the
normalization statistics. By default the last axis, the `features` axis
@ -102,11 +103,7 @@ class Normalization(base_preprocessing_layer.CombinerPreprocessingLayer):
[ 0. ]], dtype=float32)>
"""
def __init__(self, axis=-1, dtype=None, mean=None, variance=None, **kwargs):
# This ensures that if the value of K.floatx() changes after file-loading
# time, the dtype value will change to reflect it.
dtype = dtype or K.floatx()
def __init__(self, axis=-1, mean=None, variance=None, **kwargs):
# Standardize `axis` to a tuple.
if axis is None:
axis = ()
@ -116,7 +113,7 @@ class Normalization(base_preprocessing_layer.CombinerPreprocessingLayer):
axis = tuple(axis)
super(Normalization, self).__init__(
combiner=_NormalizingCombiner(axis), dtype=dtype, **kwargs)
combiner=_NormalizingCombiner(axis), **kwargs)
base_preprocessing_layer.keras_kpl_gauge.get_cell('Normalization').set(True)
if 0 in axis:

View File

@ -27,7 +27,7 @@ from tensorflow.python.util.tf_export import keras_export
@keras_export(v1=['keras.layers.experimental.preprocessing.Normalization'])
class Normalization(normalization.Normalization, CombinerPreprocessingLayer):
def __init__(self, axis=-1, dtype=None, **kwargs):
super(Normalization, self).__init__(axis, dtype, **kwargs)
def __init__(self, axis=-1, **kwargs):
super(Normalization, self).__init__(axis, **kwargs)
base_preprocessing_layer.keras_kpl_gauge.get_cell(
'Normalization v1').set(True)

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Keras categorical preprocessing layers."""
"""Keras reduction layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import

View File

@ -13,6 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Keras string lookup preprocessing layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@ -39,7 +40,7 @@ class StringLookup(index_lookup.IndexLookup):
vocabulary size, the most frequent terms will be used to create the
vocabulary.
Attributes:
Arguments:
max_tokens: The maximum size of the vocabulary for this layer. If None,
there is no cap on the size of the vocabulary. Note that this vocabulary
includes the OOV and mask tokens, so the effective number of tokens is

View File

@ -13,6 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Keras text vectorization preprocessing layer."""
# pylint: disable=g-classes-have-attributes
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@ -117,7 +118,7 @@ class TextVectorization(base_preprocessing_layer.CombinerPreprocessingLayer):
["another", "string", "to", "split"]]`. This makes the callable site
natively compatible with `tf.strings.split()`.
Attributes:
Arguments:
max_tokens: The maximum size of the vocabulary for this layer. If None,
there is no cap on the size of the vocabulary. Note that this vocabulary
contains 1 OOV token, so the effective number of tokens is `(max_tokens -
@ -162,6 +163,7 @@ class TextVectorization(base_preprocessing_layer.CombinerPreprocessingLayer):
times, an error will be thrown.
Example:
This example instantiates a TextVectorization layer that lowercases text,
splits on whitespace, strips punctuation, and outputs integer vocab indices.
@ -202,6 +204,7 @@ class TextVectorization(base_preprocessing_layer.CombinerPreprocessingLayer):
[1, 3, 0, 0]])
Example:
This example instantiates a TextVectorization layer by passing a list
of vocabulary terms to the layer's __init__ method.

View File

@ -133,7 +133,7 @@ tf_class {
}
member_method {
name: "__init__"
argspec: "args=[\'self\', \'axis\', \'dtype\'], varargs=None, keywords=kwargs, defaults=[\'-1\', \'None\'], "
argspec: "args=[\'self\', \'axis\'], varargs=None, keywords=kwargs, defaults=[\'-1\'], "
}
member_method {
name: "adapt"

View File

@ -131,7 +131,7 @@ tf_class {
}
member_method {
name: "__init__"
argspec: "args=[\'self\', \'axis\', \'dtype\', \'mean\', \'variance\'], varargs=None, keywords=kwargs, defaults=[\'-1\', \'None\', \'None\', \'None\'], "
argspec: "args=[\'self\', \'axis\', \'mean\', \'variance\'], varargs=None, keywords=kwargs, defaults=[\'-1\', \'None\', \'None\'], "
}
member_method {
name: "adapt"