reminisce commented on a change in pull request #10425: [MXNET-175] 
NdArrayiterator dict fix
URL: https://github.com/apache/incubator-mxnet/pull/10425#discussion_r180854421
 
 

 ##########
 File path: python/mxnet/module/base_module.py
 ##########
 @@ -244,6 +245,22 @@ def score(self, eval_data, eval_metric, num_batch=None, 
batch_end_callback=None,
         eval_metric.reset()
         actual_num_batch = 0
 
+        # If NDArrayIter data provided is a dict. This makes sure that only 
relevant data items
+        # matching the data names, provided during bind time, are send for 
eval.
+        orig_eval_data = None
+        if isinstance(eval_data, io.NDArrayIter) and \
+                not eval_data.renamed_data and \
+                eval_data.data and \
+                isinstance(eval_data.data[0], tuple):
+            # Keeping a copy of original data.
+            orig_eval_data = eval_data.data
+            data_dict = dict(eval_data.data)
+
+            for k, _ in eval_data.data:
+                if k not in self.data_names:
+                    del data_dict[k]
+            eval_data.data = list(data_dict.items())
 
 Review comment:
   Sort?
   This piece of code could be shared with the one in `predict()`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to