diff options
Diffstat (limited to 'tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py')
-rw-r--r-- | tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py b/tensorflow/contrib/linear_optimizer/python/ops/sdca_ops.py index 86d8484391..13f2f0f502 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_sparse = 0.0 + result = 0.0 for sfc, sv in zip(examples['sparse_features'], sparse_variables): # TODO(sibyl-Aix6ihai): following does not take care of missing features. - result_sparse += math_ops.segment_sum( + result += math_ops.segment_sum( math_ops.multiply( array_ops.gather(sv, sfc.feature_indices), sfc.feature_values), sfc.example_indices) @@ -249,13 +249,12 @@ 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_dense += math_ops.matmul( - dense_features[i], array_ops.expand_dims(dense_variables[i], -1)) + result += 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_dense, [-1]) + result_sparse + return array_ops.reshape(result, [-1]) def predictions(self, examples): """Add operations to compute predictions by the model. |