tf.tpu.experimental.embedding.Adagrad
Stay organized with collections
Save and categorize content based on your preferences.
Optimization parameters for Adagrad with TPU embeddings.
tf.tpu.experimental.embedding.Adagrad(
learning_rate: Union[float, Callable[[], float]] = 0.001,
initial_accumulator_value: float = 0.1,
use_gradient_accumulation: bool = True,
clip_weight_min: Optional[float] = None,
clip_weight_max: Optional[float] = None,
weight_decay_factor: Optional[float] = None,
multiply_weight_decay_factor_by_learning_rate: Optional[bool] = None,
slot_variable_creation_fn: Optional[SlotVarCreationFnType] = None,
clipvalue: Optional[ClipValueType] = None,
low_dimensional_packing_status: bool = False
)
Pass this to tf.tpu.experimental.embedding.TPUEmbedding
via the optimizer
argument to set the global optimizer and its parameters:
embedding = tf.tpu.experimental.embedding.TPUEmbedding(
...
optimizer=tf.tpu.experimental.embedding.Adagrad(0.1))
This can also be used in a tf.tpu.experimental.embedding.TableConfig
as the
optimizer parameter to set a table specific optimizer. This will override the
optimizer and parameters for global embedding optimizer defined above:
table_one = tf.tpu.experimental.embedding.TableConfig(
vocabulary_size=...,
dim=...,
optimizer=tf.tpu.experimental.embedding.Adagrad(0.2))
table_two = tf.tpu.experimental.embedding.TableConfig(
vocabulary_size=...,
dim=...)
feature_config = (
tf.tpu.experimental.embedding.FeatureConfig(
table=table_one),
tf.tpu.experimental.embedding.FeatureConfig(
table=table_two))
embedding = tf.tpu.experimental.embedding.TPUEmbedding(
feature_config=feature_config,
batch_size=...
optimizer=tf.tpu.experimental.embedding.Adagrad(0.1))
In the above example, the first feature will be looked up in a table that has
a learning rate of 0.2 while the second feature will be looked up in a table
that has a learning rate of 0.1.
See 'tensorflow/core/protobuf/tpu/optimization_parameters.proto' for a
complete description of these parameters and their impacts on the optimizer
algorithm.
Args |
learning_rate
|
The learning rate. It should be a floating point value or a
callable taking no arguments for a dynamic learning rate.
|
initial_accumulator_value
|
initial accumulator for Adagrad.
|
use_gradient_accumulation
|
setting this to False makes embedding
gradients calculation less accurate but faster.
|
clip_weight_min
|
the minimum value to clip by; None means -infinity.
|
clip_weight_max
|
the maximum value to clip by; None means +infinity.
|
weight_decay_factor
|
amount of weight decay to apply; None means that the
weights are not decayed.
|
multiply_weight_decay_factor_by_learning_rate
|
if true,
weight_decay_factor is multiplied by the current learning rate.
|
slot_variable_creation_fn
|
If you wish do directly control the creation of
the slot variables, set this to a callable taking three parameters: a
table variable, a list of slot names to create for it, and a list of
initializers. This function should return a dict with the slot names as
keys and the created variables as values with types matching the table
variable. When set to None (the default), uses the built-in variable
creation.
|
clipvalue
|
Controls clipping of the gradient. Set to either a single
positive scalar value to get clipping or a tuple of scalar values (min,
max) to set a separate maximum or minimum. If one of the two entries is
None, then there will be no clipping that direction.
|
low_dimensional_packing_status
|
Status of the low-dimensional embedding
packing optimization controls whether to optimize the packing of
1-dimensional, 2-dimensional, and 4-dimensional embedding tables in
memory.
|
Methods
__eq__
View source
__eq__(
other: Any
) -> Union[Any, bool]
Return self==value.
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.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.tpu.experimental.embedding.Adagrad\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/tpu/tpu_embedding_v2_utils.py#L305-L431) |\n\nOptimization parameters for Adagrad with TPU embeddings.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.tpu.experimental.embedding.Adagrad`](https://www.tensorflow.org/api_docs/python/tf/tpu/experimental/embedding/Adagrad)\n\n\u003cbr /\u003e\n\n tf.tpu.experimental.embedding.Adagrad(\n learning_rate: Union[float, Callable[[], float]] = 0.001,\n initial_accumulator_value: float = 0.1,\n use_gradient_accumulation: bool = True,\n clip_weight_min: Optional[float] = None,\n clip_weight_max: Optional[float] = None,\n weight_decay_factor: Optional[float] = None,\n multiply_weight_decay_factor_by_learning_rate: Optional[bool] = None,\n slot_variable_creation_fn: Optional[SlotVarCreationFnType] = None,\n clipvalue: Optional[ClipValueType] = None,\n low_dimensional_packing_status: bool = False\n )\n\nPass this to [`tf.tpu.experimental.embedding.TPUEmbedding`](../../../../tf/tpu/experimental/embedding/TPUEmbedding) via the `optimizer`\nargument to set the global optimizer and its parameters: \n\n embedding = tf.tpu.experimental.embedding.TPUEmbedding(\n ...\n optimizer=tf.tpu.experimental.embedding.Adagrad(0.1))\n\nThis can also be used in a [`tf.tpu.experimental.embedding.TableConfig`](../../../../tf/tpu/experimental/embedding/TableConfig) as the\noptimizer parameter to set a table specific optimizer. This will override the\noptimizer and parameters for global embedding optimizer defined above: \n\n table_one = tf.tpu.experimental.embedding.TableConfig(\n vocabulary_size=...,\n dim=...,\n optimizer=tf.tpu.experimental.embedding.Adagrad(0.2))\n table_two = tf.tpu.experimental.embedding.TableConfig(\n vocabulary_size=...,\n dim=...)\n\n feature_config = (\n tf.tpu.experimental.embedding.FeatureConfig(\n table=table_one),\n tf.tpu.experimental.embedding.FeatureConfig(\n table=table_two))\n\n embedding = tf.tpu.experimental.embedding.TPUEmbedding(\n feature_config=feature_config,\n batch_size=...\n optimizer=tf.tpu.experimental.embedding.Adagrad(0.1))\n\nIn the above example, the first feature will be looked up in a table that has\na learning rate of 0.2 while the second feature will be looked up in a table\nthat has a learning rate of 0.1.\n\nSee 'tensorflow/core/protobuf/tpu/optimization_parameters.proto' for a\ncomplete description of these parameters and their impacts on the optimizer\nalgorithm.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `learning_rate` | The learning rate. It should be a floating point value or a callable taking no arguments for a dynamic learning rate. |\n| `initial_accumulator_value` | initial accumulator for Adagrad. |\n| `use_gradient_accumulation` | setting this to `False` makes embedding gradients calculation less accurate but faster. |\n| `clip_weight_min` | the minimum value to clip by; None means -infinity. |\n| `clip_weight_max` | the maximum value to clip by; None means +infinity. |\n| `weight_decay_factor` | amount of weight decay to apply; None means that the weights are not decayed. |\n| `multiply_weight_decay_factor_by_learning_rate` | if true, `weight_decay_factor` is multiplied by the current learning rate. |\n| `slot_variable_creation_fn` | If you wish do directly control the creation of the slot variables, set this to a callable taking three parameters: a table variable, a list of slot names to create for it, and a list of initializers. This function should return a dict with the slot names as keys and the created variables as values with types matching the table variable. When set to None (the default), uses the built-in variable creation. |\n| `clipvalue` | Controls clipping of the gradient. Set to either a single positive scalar value to get clipping or a tuple of scalar values (min, max) to set a separate maximum or minimum. If one of the two entries is None, then there will be no clipping that direction. |\n| `low_dimensional_packing_status` | Status of the low-dimensional embedding packing optimization controls whether to optimize the packing of 1-dimensional, 2-dimensional, and 4-dimensional embedding tables in memory. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `__eq__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/tpu/tpu_embedding_v2_utils.py#L176-L183) \n\n __eq__(\n other: Any\n ) -\u003e Union[Any, bool]\n\nReturn self==value."]]