热启动的词汇信息。
用法
tf.estimator.VocabInfo(
new_vocab, new_vocab_size, num_oov_buckets, old_vocab, old_vocab_size=-1,
backup_initializer=None, axis=0
)
有关使用 VocabInfo 进行热启动的示例,请参阅tf.estimator.WarmStartSettings
。
Args:new_vocab:[必需] 新词汇文件的路径(与要训练的模型一起使用)。 new_vocab_size:[必需] 一个整数,表示将在训练中使用多少新词汇表条目。 num_oov_buckets:[必需] 一个整数,指示有多少 OOV 桶与词汇表相关联。 old_vocab:[必需] 旧词汇文件的路径(用于热启动的检查点)。 old_vocab_size:[可选] 一个整数,指示在创建检查点时使用了多少旧词汇表条目。如果未提供,将使用整个旧词汇表。 backup_initializer:[可选] 变量初始化器,用于对应于新词汇条目和 OOV 的变量。如果未提供,这些条目将被零初始化。 axis:[可选] 表示词汇表对应的轴。默认值 0 对应于最常见的用例(二进制分类/回归的嵌入或线性权重)。轴 1 可用于热启动具有类词汇的输出层。
返回:VocabInfo
,表示热启动的词汇信息。
引发:ValueError:axis
既不是 0 也不是 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.
```
Attributes
`new_vocab`
A `namedtuple` alias for field number 0
`new_vocab_size`
A `namedtuple` alias for field number 1
`num_oov_buckets`
A `namedtuple` alias for field number 2
`old_vocab`
A `namedtuple` alias for field number 3
`old_vocab_size`
A `namedtuple` alias for field number 4
`backup_initializer`
A `namedtuple` alias for field number 5
`axis`
A `namedtuple` alias for field number 6
相关用法
- Python tf.estimator.TrainSpec用法及代码示例
- Python tf.estimator.LogisticRegressionHead用法及代码示例
- Python tf.estimator.MultiHead用法及代码示例
- Python tf.estimator.PoissonRegressionHead用法及代码示例
- Python tf.estimator.WarmStartSettings用法及代码示例
- Python tf.estimator.experimental.stop_if_lower_hook用法及代码示例
- Python tf.estimator.RunConfig用法及代码示例
- Python tf.estimator.MultiLabelHead用法及代码示例
- Python tf.estimator.experimental.stop_if_no_increase_hook用法及代码示例
- Python tf.estimator.BaselineEstimator用法及代码示例
- Python tf.estimator.DNNLinearCombinedEstimator用法及代码示例
- Python tf.estimator.Estimator用法及代码示例
- Python tf.estimator.experimental.LinearSDCA用法及代码示例
- Python tf.estimator.experimental.RNNClassifier用法及代码示例
- Python tf.estimator.experimental.make_early_stopping_hook用法及代码示例
- Python tf.estimator.LinearRegressor用法及代码示例
- Python tf.estimator.LinearEstimator用法及代码示例
- Python tf.estimator.DNNClassifier用法及代码示例
- Python tf.estimator.BaselineClassifier用法及代码示例
- Python tf.estimator.experimental.stop_if_higher_hook用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.estimator.VocabInfo。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。