LostTech.TensorFlow : API Documentation

Type SdcaModel

Namespace tensorflow.contrib.linear_optimizer

Parent PythonObjectContainer

Interfaces ISdcaModel

Stochastic dual coordinate ascent solver for linear models.

Loss functions supported:

* Binary logistic loss * Squared loss * Hinge loss * Smooth hinge loss * Poisson log loss

This class defines an optimizer API to train a linear model.

### Usage In the training program you will just have to run the returned Op from minimize().
Show Example
# Create a solver with the desired parameters.
            lr = tf.contrib.linear_optimizer.SdcaModel(examples, variables, options)
            min_op = lr.minimize()
            opt_op = lr.update_weights(min_op) 

predictions = lr.predictions(examples) # Primal loss + L1 loss + L2 loss. regularized_loss = lr.regularized_loss(examples) # Primal loss only unregularized_loss = lr.unregularized_loss(examples)

examples: { sparse_features: list of SparseFeatureColumn. dense_features: list of dense tensors of type float32. example_labels: a tensor of type float32 and shape [Num examples] example_weights: a tensor of type float32 and shape [Num examples] example_ids: a tensor of type string and shape [Num examples] } variables: { sparse_features_weights: list of tensors of shape [vocab size] dense_features_weights: list of tensors of shape [dense_feature_dimension] } options: { symmetric_l1_regularization: 0.0 symmetric_l2_regularization: 1.0 loss_type: "logistic_loss" num_loss_partitions: 1 (Optional, with default value of 1. Number of partitions of the global loss function, 1 means single machine solver, and >1 when we have more than one optimizer working concurrently.) num_table_shards: 1 (Optional, with default value of 1. Number of shards of the internal state table, typically set to match the number of parameter servers for large data sets. }

Methods

Properties

Public instance methods

object predictions(IDictionary<string, object> examples)

Add operations to compute predictions by the model.

If logistic_loss is being used, predicted probabilities are returned. If poisson_loss is being used, predictions are exponentiated. Otherwise, (raw) linear predictions (w*x) are returned.
Parameters
IDictionary<string, object> examples
Examples to compute predictions on.
Returns
object
An Operation that computes the predictions for examples.

object regularized_loss(IDictionary<string, object> examples)

Add operations to compute the loss with regularization loss included.
Parameters
IDictionary<string, object> examples
Examples to compute loss on.
Returns
object
An Operation that computes mean (regularized) loss for given set of examples.

object unregularized_loss(IDictionary<string, object> examples)

Add operations to compute the loss (without the regularization loss).
Parameters
IDictionary<string, object> examples
Examples to compute unregularized loss on.
Returns
object
An Operation that computes mean (unregularized) loss for given set of examples.

Public properties

object PythonObject get;