tf.compat.v1.train.VocabInfo
Stay organized with collections
Save and categorize content based on your preferences.
Vocabulary information for warm-starting.
tf.compat.v1.train.VocabInfo(
new_vocab,
new_vocab_size,
num_oov_buckets,
old_vocab,
old_vocab_size=-1,
backup_initializer=None,
axis=0
)
See tf.estimator.WarmStartSettings
for examples of using
VocabInfo to warm-start.
Args:
new_vocab: [Required] A path to the new vocabulary file (used with the model
to be trained).
new_vocab_size: [Required] An integer indicating how many entries of the new
vocabulary will used in training.
num_oov_buckets: [Required] An integer indicating how many OOV buckets are
associated with the vocabulary.
old_vocab: [Required] A path to the old vocabulary file (used with the
checkpoint to be warm-started from).
old_vocab_size: [Optional] An integer indicating how many entries of the old
vocabulary were used in the creation of the checkpoint. If not provided,
the entire old vocabulary will be used.
backup_initializer: [Optional] A variable initializer used for variables
corresponding to new vocabulary entries and OOV. If not provided, these
entries will be zero-initialized.
axis: [Optional] Denotes what axis the vocabulary corresponds to. The
default, 0, corresponds to the most common use case (embeddings or
linear weights for binary classification / regression). An axis of 1
could be used for warm-starting output layers with class vocabularies.
Returns:
A VocabInfo
which represents the vocabulary information for warm-starting.
Raises:
ValueError: axis
is neither 0 or 1.
Example Usage:
embeddings_vocab_info = tf.VocabInfo(
new_vocab='embeddings_vocab',
new_vocab_size=100,
num_oov_buckets=1,
old_vocab='pretrained_embeddings_vocab',
old_vocab_size=10000,
backup_initializer=tf.compat.v1.truncated_normal_initializer(
mean=0.0, stddev=(1 / math.sqrt(embedding_dim))),
axis=0)
softmax_output_layer_kernel_vocab_info = tf.VocabInfo(
new_vocab='class_vocab',
new_vocab_size=5,
num_oov_buckets=0, # No OOV for classes.
old_vocab='old_class_vocab',
old_vocab_size=8,
backup_initializer=tf.compat.v1.glorot_uniform_initializer(),
axis=1)
softmax_output_layer_bias_vocab_info = tf.VocabInfo(
new_vocab='class_vocab',
new_vocab_size=5,
num_oov_buckets=0, # No OOV for classes.
old_vocab='old_class_vocab',
old_vocab_size=8,
backup_initializer=tf.compat.v1.zeros_initializer(),
axis=0)
#Currently, only axis=0 and axis=1 are supported.
```
<!-- Tabular view -->
<table class="responsive fixed orange">
<colgroup><col width="214px"><col></colgroup>
<tr><th colspan="2"><h2 class="add-link">Attributes</h2></th></tr>
<tr>
<td>
`new_vocab`<a id="new_vocab"></a>
</td>
<td>
A `namedtuple` alias for field number 0
</td>
</tr><tr>
<td>
`new_vocab_size`<a id="new_vocab_size"></a>
</td>
<td>
A `namedtuple` alias for field number 1
</td>
</tr><tr>
<td>
`num_oov_buckets`<a id="num_oov_buckets"></a>
</td>
<td>
A `namedtuple` alias for field number 2
</td>
</tr><tr>
<td>
`old_vocab`<a id="old_vocab"></a>
</td>
<td>
A `namedtuple` alias for field number 3
</td>
</tr><tr>
<td>
`old_vocab_size`<a id="old_vocab_size"></a>
</td>
<td>
A `namedtuple` alias for field number 4
</td>
</tr><tr>
<td>
`backup_initializer`<a id="backup_initializer"></a>
</td>
<td>
A `namedtuple` alias for field number 5
</td>
</tr><tr>
<td>
`axis`<a id="axis"></a>
</td>
<td>
A `namedtuple` alias for field number 6
</td>
</tr>
</table>
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 2024-04-26 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 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.train.VocabInfo\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/training/warm_starting_util.py#L32-L129) |\n\nVocabulary information for warm-starting. \n\n tf.compat.v1.train.VocabInfo(\n new_vocab,\n new_vocab_size,\n num_oov_buckets,\n old_vocab,\n old_vocab_size=-1,\n backup_initializer=None,\n axis=0\n )\n\nSee `tf.estimator.WarmStartSettings` for examples of using\nVocabInfo to warm-start.\n\nArgs:\nnew_vocab: \\[Required\\] A path to the new vocabulary file (used with the model\nto be trained).\nnew_vocab_size: \\[Required\\] An integer indicating how many entries of the new\nvocabulary will used in training.\nnum_oov_buckets: \\[Required\\] An integer indicating how many OOV buckets are\nassociated with the vocabulary.\nold_vocab: \\[Required\\] A path to the old vocabulary file (used with the\ncheckpoint to be warm-started from).\nold_vocab_size: \\[Optional\\] An integer indicating how many entries of the old\nvocabulary were used in the creation of the checkpoint. If not provided,\nthe entire old vocabulary will be used.\nbackup_initializer: \\[Optional\\] A variable initializer used for variables\ncorresponding to new vocabulary entries and OOV. If not provided, these\nentries will be zero-initialized.\naxis: \\[Optional\\] Denotes what axis the vocabulary corresponds to. The\ndefault, 0, corresponds to the most common use case (embeddings or\nlinear weights for binary classification / regression). An axis of 1\ncould be used for warm-starting output layers with class vocabularies.\n\nReturns:\nA `VocabInfo` which represents the vocabulary information for warm-starting.\n\nRaises:\nValueError: `axis` is neither 0 or 1. \n\n Example Usage:\n\n embeddings_vocab_info = tf.VocabInfo(\n new_vocab='embeddings_vocab',\n new_vocab_size=100,\n num_oov_buckets=1,\n old_vocab='pretrained_embeddings_vocab',\n old_vocab_size=10000,\n backup_initializer=tf.compat.v1.truncated_normal_initializer(\n mean=0.0, stddev=(1 / math.sqrt(embedding_dim))),\n axis=0)\n\n softmax_output_layer_kernel_vocab_info = tf.VocabInfo(\n new_vocab='class_vocab',\n new_vocab_size=5,\n num_oov_buckets=0, # No OOV for classes.\n old_vocab='old_class_vocab',\n old_vocab_size=8,\n backup_initializer=tf.compat.v1.glorot_uniform_initializer(),\n axis=1)\n\n softmax_output_layer_bias_vocab_info = tf.VocabInfo(\n new_vocab='class_vocab',\n new_vocab_size=5,\n num_oov_buckets=0, # No OOV for classes.\n old_vocab='old_class_vocab',\n old_vocab_size=8,\n backup_initializer=tf.compat.v1.zeros_initializer(),\n axis=0)\n\n #Currently, only axis=0 and axis=1 are supported.\n ```\n \n\n\n\n \u003c!-- Tabular view --\u003e\n \u003ctable class=\"responsive fixed orange\"\u003e\n \u003ccolgroup\u003e\u003ccol width=\"214px\"\u003e\u003ccol\u003e\u003c/colgroup\u003e\n \u003ctr\u003e\u003cth colspan=\"2\"\u003e\u003ch2 class=\"add-link\"\u003eAttributes\u003c/h2\u003e\u003c/th\u003e\u003c/tr\u003e\n\n \u003ctr\u003e\n \u003ctd\u003e\n `new_vocab`\u003ca id=\"new_vocab\"\u003e\u003c/a\u003e\n \u003c/td\u003e\n \u003ctd\u003e\n A `namedtuple` alias for field number 0\n \u003c/td\u003e\n \u003c/tr\u003e\u003ctr\u003e\n \u003ctd\u003e\n `new_vocab_size`\u003ca id=\"new_vocab_size\"\u003e\u003c/a\u003e\n \u003c/td\u003e\n \u003ctd\u003e\n A `namedtuple` alias for field number 1\n \u003c/td\u003e\n \u003c/tr\u003e\u003ctr\u003e\n \u003ctd\u003e\n `num_oov_buckets`\u003ca id=\"num_oov_buckets\"\u003e\u003c/a\u003e\n \u003c/td\u003e\n \u003ctd\u003e\n A `namedtuple` alias for field number 2\n \u003c/td\u003e\n \u003c/tr\u003e\u003ctr\u003e\n \u003ctd\u003e\n `old_vocab`\u003ca id=\"old_vocab\"\u003e\u003c/a\u003e\n \u003c/td\u003e\n \u003ctd\u003e\n A `namedtuple` alias for field number 3\n \u003c/td\u003e\n \u003c/tr\u003e\u003ctr\u003e\n \u003ctd\u003e\n `old_vocab_size`\u003ca id=\"old_vocab_size\"\u003e\u003c/a\u003e\n \u003c/td\u003e\n \u003ctd\u003e\n A `namedtuple` alias for field number 4\n \u003c/td\u003e\n \u003c/tr\u003e\u003ctr\u003e\n \u003ctd\u003e\n `backup_initializer`\u003ca id=\"backup_initializer\"\u003e\u003c/a\u003e\n \u003c/td\u003e\n \u003ctd\u003e\n A `namedtuple` alias for field number 5\n \u003c/td\u003e\n \u003c/tr\u003e\u003ctr\u003e\n \u003ctd\u003e\n `axis`\u003ca id=\"axis\"\u003e\u003c/a\u003e\n \u003c/td\u003e\n \u003ctd\u003e\n A `namedtuple` alias for field number 6\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003c/table\u003e"]]