28
28
from tensorflow.python.framework import dtypes
29
29
from tensorflow.python.framework import ops
30
30
from tensorflow.python.ops import control_flow_ops
31
- from tensorflow.python.ops import logging_ops
32
31
from tensorflow.python.ops import math_ops
33
32
from tensorflow.python.ops import state_ops
34
33
from tensorflow.python.platform import tf_logging as logging
@@ -130,6 +129,10 @@ def _model_fn(features, labels, mode):
130
129
inference[eval_metrics.INFERENCE_PRED_NAME] = math_ops.argmax(
131
130
inference[eval_metrics.INFERENCE_PROB_NAME], 1)
132
131
132
+ if report_feature_importances:
133
+ inference[eval_metrics.FEATURE_IMPORTANCE_NAME] = (
134
+ graph_builder.feature_importances())
135
+
133
136
# labels might be None if we're doing prediction (which brings up the
134
137
# question of why we force everything to adhere to a single model_fn).
135
138
loss_deps = []
@@ -149,10 +152,7 @@ def _model_fn(features, labels, mode):
149
152
with ops.control_dependencies(loss_deps):
150
153
training_loss = graph_builder.training_loss(
151
154
features, labels, name=LOSS_NAME)
152
- if report_feature_importances and mode == model_fn_lib.ModeKeys.EVAL:
153
- training_loss = logging_ops.Print(training_loss,
154
- [graph_builder.feature_importances()],
155
- summarize=1000)
155
+
156
156
# Put weights back in
157
157
if weights is not None:
158
158
features[weights_name] = weights
0 commit comments