tf.compat.v1.keras.layers.experimental.preprocessing.IntegerLookup
Stay organized with collections
Save and categorize content based on your preferences.
Maps integers from a vocabulary to integer indices.
Inherits From: IntegerLookup
, PreprocessingLayer
, Layer
, Module
tf.compat.v1.keras.layers.experimental.preprocessing.IntegerLookup(
max_values=None, num_oov_indices=1, mask_value=0, oov_value=-1, vocabulary=None,
invert=False, **kwargs
)
Methods
adapt
View source
adapt(
data, reset_state=True
)
Fits the state of the preprocessing layer to the dataset.
Overrides the default adapt method to apply relevant preprocessing to the
inputs before passing to the combiner.
Arguments |
data
|
The data to train on. It can be passed either as a tf.data Dataset,
or as a numpy array.
|
reset_state
|
Optional argument specifying whether to clear the state of
the layer at the start of the call to adapt . This must be True for
this layer, which does not support repeated calls to adapt .
|
get_vocabulary
View source
get_vocabulary()
set_vocabulary
View source
set_vocabulary(
vocab
)
Sets vocabulary data for this layer with inverse=False.
This method sets the vocabulary for this layer directly, instead of
analyzing a dataset through 'adapt'. It should be used whenever the vocab
information is already known. If vocabulary data is already present in the
layer, this method will either replace it
Arguments |
vocab
|
An array of string tokens.
|
Raises |
ValueError
|
If there are too many inputs, the inputs do not match, or
input data is missing.
|
vocab_size
View source
vocab_size()
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2021-02-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-02-18 UTC."],[],[],null,["# tf.compat.v1.keras.layers.experimental.preprocessing.IntegerLookup\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/layers/preprocessing/integer_lookup_v1.py#L27-L40) |\n\nMaps integers from a vocabulary to integer indices.\n\nInherits From: [`IntegerLookup`](../../../../../../../tf/keras/layers/experimental/preprocessing/IntegerLookup), [`PreprocessingLayer`](../../../../../../../tf/keras/layers/experimental/preprocessing/PreprocessingLayer), [`Layer`](../../../../../../../tf/keras/layers/Layer), [`Module`](../../../../../../../tf/Module) \n\n tf.compat.v1.keras.layers.experimental.preprocessing.IntegerLookup(\n max_values=None, num_oov_indices=1, mask_value=0, oov_value=-1, vocabulary=None,\n invert=False, **kwargs\n )\n\nMethods\n-------\n\n### `adapt`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/layers/preprocessing/index_lookup.py#L178-L193) \n\n adapt(\n data, reset_state=True\n )\n\nFits the state of the preprocessing layer to the dataset.\n\nOverrides the default adapt method to apply relevant preprocessing to the\ninputs before passing to the combiner.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments ||\n|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `data` | The data to train on. It can be passed either as a tf.data Dataset, or as a numpy array. |\n| `reset_state` | Optional argument specifying whether to clear the state of the layer at the start of the call to `adapt`. This must be True for this layer, which does not support repeated calls to `adapt`. |\n\n\u003cbr /\u003e\n\n### `get_vocabulary`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/layers/preprocessing/index_lookup.py#L195-L206) \n\n get_vocabulary()\n\n### `set_vocabulary`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/layers/preprocessing/index_lookup.py#L345-L363) \n\n set_vocabulary(\n vocab\n )\n\nSets vocabulary data for this layer with inverse=False.\n\nThis method sets the vocabulary for this layer directly, instead of\nanalyzing a dataset through 'adapt'. It should be used whenever the vocab\ninformation is already known. If vocabulary data is already present in the\nlayer, this method will either replace it\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments ||\n|---------|----------------------------|\n| `vocab` | An array of string tokens. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|--------------|----------------------------------------------------------------------------------|\n| `ValueError` | If there are too many inputs, the inputs do not match, or input data is missing. |\n\n\u003cbr /\u003e\n\n### `vocab_size`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/layers/preprocessing/index_lookup.py#L208-L209) \n\n vocab_size()"]]