aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py')
-rw-r--r--tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py57
1 files changed, 39 insertions, 18 deletions
diff --git a/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py b/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py
index b98adf862b..48ac429701 100644
--- a/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py
+++ b/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py
@@ -22,6 +22,7 @@ import collections
from six.moves import range
from tensorflow.contrib.linear_optimizer.python.ops.sharded_mutable_dense_hashtable import ShardedMutableDenseHashTable
+from tensorflow.python.compat import compat
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
@@ -485,24 +486,44 @@ class SdcaModel(object):
sparse_weights.append(batch_gathered_weights)
# pylint: disable=protected-access
- esu, sfw, dfw = gen_sdca_ops.sdca_optimizer(
- sparse_example_indices,
- sparse_feature_indices,
- sparse_features_values,
- self._convert_n_to_tensor(self._examples['dense_features']),
- internal_convert_to_tensor(self._examples['example_weights']),
- internal_convert_to_tensor(self._examples['example_labels']),
- sparse_indices,
- sparse_weights,
- self._convert_n_to_tensor(self._slots[
- 'unshrinked_dense_features_weights']),
- example_state_data,
- loss_type=self._options['loss_type'],
- l1=self._options['symmetric_l1_regularization'],
- l2=self._symmetric_l2_regularization(),
- num_loss_partitions=self._num_loss_partitions(),
- num_inner_iterations=1,
- adaptative=self._adaptive())
+ if compat.forward_compatible(year=2018, month=10, day=30):
+ esu, sfw, dfw = gen_sdca_ops.sdca_optimizer_v2(
+ sparse_example_indices,
+ sparse_feature_indices,
+ sparse_features_values,
+ self._convert_n_to_tensor(self._examples['dense_features']),
+ internal_convert_to_tensor(self._examples['example_weights']),
+ internal_convert_to_tensor(self._examples['example_labels']),
+ sparse_indices,
+ sparse_weights,
+ self._convert_n_to_tensor(self._slots[
+ 'unshrinked_dense_features_weights']),
+ example_state_data,
+ loss_type=self._options['loss_type'],
+ l1=self._options['symmetric_l1_regularization'],
+ l2=self._symmetric_l2_regularization(),
+ num_loss_partitions=self._num_loss_partitions(),
+ num_inner_iterations=1,
+ adaptive=self._adaptive())
+ else:
+ esu, sfw, dfw = gen_sdca_ops.sdca_optimizer(
+ sparse_example_indices,
+ sparse_feature_indices,
+ sparse_features_values,
+ self._convert_n_to_tensor(self._examples['dense_features']),
+ internal_convert_to_tensor(self._examples['example_weights']),
+ internal_convert_to_tensor(self._examples['example_labels']),
+ sparse_indices,
+ sparse_weights,
+ self._convert_n_to_tensor(self._slots[
+ 'unshrinked_dense_features_weights']),
+ example_state_data,
+ loss_type=self._options['loss_type'],
+ l1=self._options['symmetric_l1_regularization'],
+ l2=self._symmetric_l2_regularization(),
+ num_loss_partitions=self._num_loss_partitions(),
+ num_inner_iterations=1,
+ adaptative=self._adaptive())
# pylint: enable=protected-access
with ops.control_dependencies([esu]):