-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tensorflow
: Add missing members to the tensorflow.keras.layers
mo…
…dule. (#11333) Co-authored-by: Jelle Zijlstra <[email protected]> Co-authored-by: Rebecca Chen <[email protected]>
- Loading branch information
1 parent
56bb53a
commit 6c52322
Showing
7 changed files
with
217 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
stubs/tensorflow/tensorflow/keras/layers/experimental/preprocessing.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import abc | ||
from typing import overload | ||
|
||
import tensorflow as tf | ||
from tensorflow._aliases import AnyArray, DataSequence, Float, Integer, TensorCompatible, TensorLike | ||
from tensorflow.keras.layers import Layer | ||
|
||
class PreprocessingLayer(Layer[TensorLike, TensorLike], metaclass=abc.ABCMeta): | ||
@property | ||
def is_adapted(self) -> bool: ... | ||
@overload # type: ignore | ||
def __call__(self, inputs: tf.Tensor, *, training: bool = False, mask: TensorCompatible | None = None) -> tf.Tensor: ... | ||
@overload | ||
def __call__( | ||
self, inputs: tf.SparseTensor, *, training: bool = False, mask: TensorCompatible | None = None | ||
) -> tf.SparseTensor: ... | ||
@overload | ||
def __call__( | ||
self, inputs: tf.RaggedTensor, *, training: bool = False, mask: TensorCompatible | None = None | ||
) -> tf.RaggedTensor: ... | ||
def adapt( | ||
self, | ||
data: tf.data.Dataset[TensorLike] | AnyArray | DataSequence, | ||
batch_size: Integer | None = None, | ||
steps: Float | None = None, | ||
) -> None: ... | ||
def compile(self, run_eagerly: bool | None = None, steps_per_execution: Integer | None = None) -> None: ... |
36 changes: 36 additions & 0 deletions
36
stubs/tensorflow/tensorflow/keras/layers/preprocessing/__init__.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Literal | ||
|
||
from tensorflow._aliases import TensorCompatible | ||
from tensorflow.keras.layers.preprocessing.index_lookup import _IndexLookup | ||
|
||
class StringLookup(_IndexLookup): | ||
def __init__( | ||
self, | ||
max_tokens: int | None = None, | ||
num_oov_indices: int = 1, | ||
mask_token: str | None = None, | ||
oov_token: str = "[UNK]", | ||
vocabulary: str | None | TensorCompatible = None, | ||
idf_weights: TensorCompatible | None = None, | ||
encoding: str = "utf-8", | ||
invert: bool = False, | ||
output_mode: Literal["int", "count", "multi_hot", "one_hot", "tf_idf"] = "int", | ||
sparse: bool = False, | ||
pad_to_max_tokens: bool = False, | ||
) -> None: ... | ||
|
||
class IntegerLookup(_IndexLookup): | ||
def __init__( | ||
self, | ||
max_tokens: int | None = None, | ||
num_oov_indices: int = 1, | ||
mask_token: int | None = None, | ||
oov_token: int = -1, | ||
vocabulary: str | None | TensorCompatible = None, | ||
vocabulary_dtype: Literal["int64", "int32"] = "int64", | ||
idf_weights: TensorCompatible | None = None, | ||
invert: bool = False, | ||
output_mode: Literal["int", "count", "multi_hot", "one_hot", "tf_idf"] = "int", | ||
sparse: bool = False, | ||
pad_to_max_tokens: bool = False, | ||
) -> None: ... |
9 changes: 9 additions & 0 deletions
9
stubs/tensorflow/tensorflow/keras/layers/preprocessing/index_lookup.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from _typeshed import Incomplete | ||
|
||
import tensorflow as tf | ||
from tensorflow.keras.layers.experimental.preprocessing import PreprocessingLayer | ||
|
||
class _IndexLookup(PreprocessingLayer): | ||
def compute_output_signature(self, input_spec: Incomplete) -> tf.TensorSpec: ... | ||
def get_vocabulary(self, include_special_tokens: bool = True) -> list[Incomplete]: ... | ||
def vocabulary_size(self) -> int: ... |