From 3e1a0792fb593953860162d57320c8602fd199eb Mon Sep 17 00:00:00 2001 From: Yuefeng Zhou Date: Tue, 9 Oct 2018 09:32:50 -0700 Subject: Create SDCAOptimizerV2 op to fix the "adaptative" typo. PiperOrigin-RevId: 216370193 --- .../api_def/base_api/api_def_SdcaOptimizerV2.pbtxt | 171 +++++++++++++++++++++ tensorflow/core/kernels/sdca_ops.cc | 8 +- tensorflow/core/ops/sdca_ops.cc | 28 ++++ 3 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 tensorflow/core/api_def/base_api/api_def_SdcaOptimizerV2.pbtxt (limited to 'tensorflow/core') diff --git a/tensorflow/core/api_def/base_api/api_def_SdcaOptimizerV2.pbtxt b/tensorflow/core/api_def/base_api/api_def_SdcaOptimizerV2.pbtxt new file mode 100644 index 0000000000..c615dee8c7 --- /dev/null +++ b/tensorflow/core/api_def/base_api/api_def_SdcaOptimizerV2.pbtxt @@ -0,0 +1,171 @@ +op { + graph_op_name: "SdcaOptimizerV2" + visibility: HIDDEN + in_arg { + name: "sparse_example_indices" + description: < +Shai Shalev-Shwartz, Tong Zhang. 2012 + +$$Loss Objective = \sum f_{i} (wx_{i}) + (l2 / 2) * |w|^2 + l1 * |w|$$ + +[Adding vs. Averaging in Distributed Primal-Dual Optimization](http://arxiv.org/abs/1502.03508).
+Chenxin Ma, Virginia Smith, Martin Jaggi, Michael I. Jordan, +Peter Richtarik, Martin Takac. 2015 + +[Stochastic Dual Coordinate Ascent with Adaptive Probabilities](https://arxiv.org/abs/1502.08053).
+Dominik Csiba, Zheng Qu, Peter Richtarik. 2015 +END +} diff --git a/tensorflow/core/kernels/sdca_ops.cc b/tensorflow/core/kernels/sdca_ops.cc index 3bd4168dc7..d0e0b15da7 100644 --- a/tensorflow/core/kernels/sdca_ops.cc +++ b/tensorflow/core/kernels/sdca_ops.cc @@ -83,7 +83,11 @@ struct ComputeOptions { context, false, errors::InvalidArgument("Unsupported loss type: ", loss_type)); } - OP_REQUIRES_OK(context, context->GetAttr("adaptative", &adaptive)); + auto s = context->GetAttr("adaptative", &adaptive); + if (!s.ok()) { + s = context->GetAttr("adaptive", &adaptive); + } + OP_REQUIRES_OK(context, s); OP_REQUIRES_OK( context, context->GetAttr("num_sparse_features", &num_sparse_features)); OP_REQUIRES_OK(context, context->GetAttr("num_sparse_features_with_values", @@ -245,6 +249,8 @@ class SdcaOptimizer : public OpKernel { }; REGISTER_KERNEL_BUILDER(Name("SdcaOptimizer").Device(DEVICE_CPU), SdcaOptimizer); +REGISTER_KERNEL_BUILDER(Name("SdcaOptimizerV2").Device(DEVICE_CPU), + SdcaOptimizer); class SdcaShrinkL1 : public OpKernel { public: diff --git a/tensorflow/core/ops/sdca_ops.cc b/tensorflow/core/ops/sdca_ops.cc index fdf53a55dd..51d248f2d6 100644 --- a/tensorflow/core/ops/sdca_ops.cc +++ b/tensorflow/core/ops/sdca_ops.cc @@ -65,6 +65,34 @@ REGISTER_OP("SdcaOptimizer") .Output("out_delta_dense_weights: num_dense_features * float") .SetShapeFn(ApplySdcaOptimizerShapeFn); +// The SdcaOptimizerV2 op fixes the "adaptative" typo in v1. +REGISTER_OP("SdcaOptimizerV2") + .Attr( + "loss_type: {'logistic_loss', 'squared_loss', 'hinge_loss'," + "'smooth_hinge_loss', 'poisson_loss'}") + .Attr("adaptive : bool=false") + .Attr("num_sparse_features: int >= 0") + .Attr("num_sparse_features_with_values: int >= 0") + .Attr("num_dense_features: int >= 0") + .Attr("l1: float") + .Attr("l2: float") + .Attr("num_loss_partitions: int >= 1") + .Attr("num_inner_iterations: int >= 1") + .Input("sparse_example_indices: num_sparse_features * int64") + .Input("sparse_feature_indices: num_sparse_features * int64") + .Input("sparse_feature_values: num_sparse_features_with_values * float") + .Input("dense_features: num_dense_features * float") + .Input("example_weights: float") + .Input("example_labels: float") + .Input("sparse_indices: num_sparse_features * int64") + .Input("sparse_weights: num_sparse_features * float") + .Input("dense_weights: num_dense_features * float") + .Input("example_state_data: float") + .Output("out_example_state_data: float") + .Output("out_delta_sparse_weights: num_sparse_features * float") + .Output("out_delta_dense_weights: num_dense_features * float") + .SetShapeFn(ApplySdcaOptimizerShapeFn); + REGISTER_OP("SdcaShrinkL1") .Attr("num_features: int >= 0") .Attr("l1: float") -- cgit v1.2.3