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.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py b/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py
index 13f2f0f502..86d8484391 100644
--- a/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py
+++ b/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py
@@ -238,10 +238,10 @@ class SdcaModel(object):
with name_scope('sdca/prediction'):
sparse_variables = self._convert_n_to_tensor(self._variables[
'sparse_features_weights'])
- result = 0.0
+ result_sparse = 0.0
for sfc, sv in zip(examples['sparse_features'], sparse_variables):
# TODO(sibyl-Aix6ihai): following does not take care of missing features.
- result += math_ops.segment_sum(
+ result_sparse += math_ops.segment_sum(
math_ops.multiply(
array_ops.gather(sv, sfc.feature_indices), sfc.feature_values),
sfc.example_indices)
@@ -249,12 +249,13 @@ class SdcaModel(object):
dense_variables = self._convert_n_to_tensor(self._variables[
'dense_features_weights'])
+ result_dense = 0.0
for i in range(len(dense_variables)):
- result += math_ops.matmul(dense_features[i],
- array_ops.expand_dims(dense_variables[i], -1))
+ result_dense += math_ops.matmul(
+ dense_features[i], array_ops.expand_dims(dense_variables[i], -1))
# Reshaping to allow shape inference at graph construction time.
- return array_ops.reshape(result, [-1])
+ return array_ops.reshape(result_dense, [-1]) + result_sparse
def predictions(self, examples):
"""Add operations to compute predictions by the model.