tf.estimator.experimental.LinearSDCA
Stay organized with collections
Save and categorize content based on your preferences.
Stochastic Dual Coordinate Ascent helper for linear estimators.
tf.estimator.experimental.LinearSDCA(
example_id_column, num_loss_partitions=1, num_table_shards=None,
symmetric_l1_regularization=0.0, symmetric_l2_regularization=1.0, adaptive=False
)
Objects of this class are intended to be provided as the optimizer argument
(though LinearSDCA objects do not implement the tf.train.Optimizer
interface)
when creating tf.estimator.LinearClassifier
or tf.estimator.LinearRegressor
.
SDCA can only be used with LinearClassifier
and LinearRegressor
under the
following conditions:
- Feature columns are of type V2.
- Multivalent categorical columns are not normalized. In other words the
sparse_combiner
argument in the estimator constructor should be "sum".
- For classification: binary label.
- For regression: one-dimensional label.
Example usage:
real_feature_column = numeric_column(...)
sparse_feature_column = categorical_column_with_hash_bucket(...)
linear_sdca = tf.estimator.experimental.LinearSDCA(
example_id_column='example_id',
num_loss_partitions=1,
num_table_shards=1,
symmetric_l2_regularization=2.0)
classifier = tf.estimator.LinearClassifier(
feature_columns=[real_feature_column, sparse_feature_column],
weight_column=...,
optimizer=linear_sdca)
classifier.train(input_fn_train, steps=50)
classifier.evaluate(input_fn=input_fn_eval)
Here the expectation is that the input_fn_*
functions passed to train and
evaluate return a pair (dict, label_tensor) where dict has example_id_column
as key
whose value is a Tensor
of shape [batch_size] and dtype string.
num_loss_partitions defines sigma' in eq (11) of [3]. Convergence of (global)
loss is guaranteed if num_loss_partitions
is larger or equal to the product
(#concurrent train ops/per worker) x (#workers)
. Larger values for
num_loss_partitions
lead to slower convergence. The recommended value for
num_loss_partitions
in tf.estimator
(where currently there is one process
per worker) is the number of workers running the train steps. It defaults to 1
(single machine).
num_table_shards
defines the number of shards for the internal state
table, typically set to match the number of parameter servers for large
data sets.
The SDCA algorithm was originally introduced in [1] and it was followed by
the L1 proximal step [2], a distributed version [3] and adaptive sampling [4].
[1] www.jmlr.org/papers/volume14/shalev-shwartz13a/shalev-shwartz13a.pdf
[2] https://arxiv.org/pdf/1309.2375.pdf
[3] https://arxiv.org/pdf/1502.03508.pdf
[4] https://arxiv.org/pdf/1502.08053.pdf
Details specific to this implementation are provided in:
https://github.com/tensorflow/estimator/tree/master/tensorflow_estimator/python/estimator/canned/linear_optimizer/doc/sdca.ipynb
Args |
example_id_column
|
The column name containing the example ids.
|
num_loss_partitions
|
Number of workers.
|
num_table_shards
|
Number of shards of the internal state table, typically
set to match the number of parameter servers.
|
symmetric_l1_regularization
|
A float value, must be greater than or
equal to zero.
|
symmetric_l2_regularization
|
A float value, must be greater than zero and
should typically be greater than 1.
|
adaptive
|
A boolean indicating whether to use adaptive sampling.
|
Methods
get_train_step
View source
get_train_step(
state_manager, weight_column_name, loss_type, feature_columns, features,
targets, bias_var, global_step
)
Returns the training operation of an SdcaModel optimizer.
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.
Last updated 2020-10-01 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 2020-10-01 UTC."],[],[],null,["# tf.estimator.experimental.LinearSDCA\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/estimator/experimental/LinearSDCA) | [View source on GitHub](https://github.com/tensorflow/estimator/tree/master/tensorflow_estimator/python/estimator/canned/linear.py) |\n\nStochastic Dual Coordinate Ascent helper for linear estimators.\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.estimator.experimental.LinearSDCA`](/api_docs/python/tf/estimator/experimental/LinearSDCA)\n\n\u003cbr /\u003e\n\n tf.estimator.experimental.LinearSDCA(\n example_id_column, num_loss_partitions=1, num_table_shards=None,\n symmetric_l1_regularization=0.0, symmetric_l2_regularization=1.0, adaptive=False\n )\n\nObjects of this class are intended to be provided as the optimizer argument\n(though LinearSDCA objects do not implement the `tf.train.Optimizer` interface)\nwhen creating [`tf.estimator.LinearClassifier`](../../../tf/estimator/LinearClassifier) or [`tf.estimator.LinearRegressor`](../../../tf/estimator/LinearRegressor).\n\nSDCA can only be used with `LinearClassifier` and `LinearRegressor` under the\nfollowing conditions:\n\n- Feature columns are of type V2.\n- Multivalent categorical columns are not normalized. In other words the `sparse_combiner` argument in the estimator constructor should be \"sum\".\n- For classification: binary label.\n- For regression: one-dimensional label.\n\n#### Example usage:\n\n real_feature_column = numeric_column(...)\n sparse_feature_column = categorical_column_with_hash_bucket(...)\n linear_sdca = tf.estimator.experimental.LinearSDCA(\n example_id_column='example_id',\n num_loss_partitions=1,\n num_table_shards=1,\n symmetric_l2_regularization=2.0)\n classifier = tf.estimator.LinearClassifier(\n feature_columns=[real_feature_column, sparse_feature_column],\n weight_column=...,\n optimizer=linear_sdca)\n classifier.train(input_fn_train, steps=50)\n classifier.evaluate(input_fn=input_fn_eval)\n\nHere the expectation is that the `input_fn_*` functions passed to train and\nevaluate return a pair (dict, label_tensor) where dict has `example_id_column`\nas `key` whose value is a `Tensor` of shape \\[batch_size\\] and dtype string.\nnum_loss_partitions defines sigma' in eq (11) of \\[3\\]. Convergence of (global)\nloss is guaranteed if `num_loss_partitions` is larger or equal to the product\n`(#concurrent train ops/per worker) x (#workers)`. Larger values for\n`num_loss_partitions` lead to slower convergence. The recommended value for\n`num_loss_partitions` in [`tf.estimator`](../../../tf/estimator) (where currently there is one process\nper worker) is the number of workers running the train steps. It defaults to 1\n(single machine).\n`num_table_shards` defines the number of shards for the internal state\ntable, typically set to match the number of parameter servers for large\ndata sets.\n\nThe SDCA algorithm was originally introduced in \\[1\\] and it was followed by\nthe L1 proximal step \\[2\\], a distributed version \\[3\\] and adaptive sampling \\[4\\].\n\\[1\\] www.jmlr.org/papers/volume14/shalev-shwartz13a/shalev-shwartz13a.pdf\n\\[2\\] \u003chttps://arxiv.org/pdf/1309.2375.pdf\u003e\n\\[3\\] \u003chttps://arxiv.org/pdf/1502.03508.pdf\u003e\n\\[4\\] \u003chttps://arxiv.org/pdf/1502.08053.pdf\u003e\nDetails specific to this implementation are provided in:\n\u003chttps://github.com/tensorflow/estimator/tree/master/tensorflow_estimator/python/estimator/canned/linear_optimizer/doc/sdca.ipynb\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------------------|-------------------------------------------------------------------------------------------------------|\n| `example_id_column` | The column name containing the example ids. |\n| `num_loss_partitions` | Number of workers. |\n| `num_table_shards` | Number of shards of the internal state table, typically set to match the number of parameter servers. |\n| `symmetric_l1_regularization` | A float value, must be greater than or equal to zero. |\n| `symmetric_l2_regularization` | A float value, must be greater than zero and should typically be greater than 1. |\n| `adaptive` | A boolean indicating whether to use adaptive sampling. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `get_train_step`\n\n[View source](https://github.com/tensorflow/estimator/tree/master/tensorflow_estimator/python/estimator/canned/linear.py) \n\n get_train_step(\n state_manager, weight_column_name, loss_type, feature_columns, features,\n targets, bias_var, global_step\n )\n\nReturns the training operation of an SdcaModel optimizer."]]