Closed FarooqKhan closed 4 years ago
Thanks for the note.
I don't think we want dataset.map()
to handle invalid tensors. Instead, we can probably make _parse_tf_example_fn
return just the features and no labels in PREDICT
mode. Specifically, change implementation of _parse_tf_example_fn
from:
labels = None
if mode != tf.estimator.ModeKeys.PREDICT:
labels = parsed_features["class_index"]
parsed_features["ink"] = tf.sparse_tensor_to_dense(parsed_features["ink"])
return parsed_features, labels
to:
parsed_features["ink"] = tf.sparse_tensor_to_dense(parsed_features["ink"])
if mode != tf.estimator.ModeKeys.PREDICT:
labels = parsed_features["class_index"]
return parsed_features, labels
return parsed_features
Could you give that a spin? If that works, then we'd be more than happy to accept a pull request with that change. Thanks!
I totally agree with your reply, I have raised a PR 3440. I have tested this change and this part works fine. However, I do want to mention that I have been trying out predict and so far have not succeeded completely so cannot be 100% sure about this change.
Hi There, We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing. If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.
System information
Describe the problem
Am trying to do a prediction for this tutorial and building on the existing code in train_model.py.
To do this I am trying to reuse the
get_input_fn()
function for prediction. I think the inner function_parse_tfexample_fn()
seems to be coded for use during prediction as well as it has few if conditions checking for mode == PREDICTI am invoking it as follows:
_parse_tfexample_fn()
returns a tuple of 'parsed_features, labels' and labels is None whenmode == PREDICT
However this then causes causes a exception as below which is due to the labels being None i think.Maybe the
dataset.map()
should check for None value before invokingget_shape()
on it?