Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TensorFlow-gpu 2.0 - Forward features in estimators prediction output #34418

Closed
jusingh opened this issue Nov 19, 2019 · 2 comments
Closed

TensorFlow-gpu 2.0 - Forward features in estimators prediction output #34418

jusingh opened this issue Nov 19, 2019 · 2 comments
Assignees
Labels
comp:apis Highlevel API related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.0 Issues relating to TensorFlow 2.0 type:feature Feature requests

Comments

@jusingh
Copy link

jusingh commented Nov 19, 2019

System information

  • TensorFlow version (you are using): 2.0
  • Are you willing to contribute it (Yes/No): No

Describe the feature and the current behavior/state.

In tensorflow-gpu 1.14, we were passing the ID key(s) as a forward feature so that it appears in prediction outputs

estimator = tf.contrib.estimator.forward_features(
estimator,
keys=[
feature_forward_key.name
for feature_forward_key in metadata.FEATURE_FORWARD_KEYS
])

On migrating the code to Tensorflow-gpu 2.0, tf.contrib package is removed and we couldn't find forward-features functionality in tensorflow core for an estimator.

Will this change the current api? How? No

Who will benefit with this feature? Everyone

Any Other info.

@ravikyram ravikyram self-assigned this Nov 20, 2019
@ravikyram ravikyram added comp:apis Highlevel API related issues TF 2.0 Issues relating to TensorFlow 2.0 type:feature Feature requests labels Nov 20, 2019
@jvishnuvardhan jvishnuvardhan added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Nov 20, 2019
@karmel
Copy link

karmel commented Nov 21, 2019

Contrib.estimator has been deprecated for quite some time. If you still need this functionality, I would recommend forking it. The code as-is is a relatively short function, and you could likely clean it up even further if it only needs to support your use-case.

@karmel karmel closed this as completed Nov 21, 2019
@TomScheffers
Copy link

I had the same issue. The "bare-bones" solution is quite easy:

def forward_features(estimator, key):
    def new_model_fn(features, labels, mode, config):
        spec = estimator.model_fn(features, labels, mode, config)
        predictions = spec.predictions
        predictions[key] = features[key]
        spec = spec._replace(predictions=predictions)
        return spec
    return tf.estimator.Estimator(model_fn=new_model_fn, model_dir=estimator.model_dir, config=estimator.config)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:apis Highlevel API related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.0 Issues relating to TensorFlow 2.0 type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

5 participants