-
Notifications
You must be signed in to change notification settings - Fork 529
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
How-to serve #22
Comments
If you want to test predictions on a few batches or a In order to serve for a live data feed, you first need to call |
Sorry for a dumb question, but if it will keep me and anyone else having this issue from banging their head against the keyboard, I will ask it. I've been testing the tutorial model for the boston house prices and am also trying to get Estimator.predict to predict. I can export the model, but calling predict always gives one of two errors.
calling next(final_prediction) results in
Giving input_fn with partition=test:
I get the same errors calling I assume I'm missing something trivial. Thanks for the great work! |
It would be great if we could get the sample code on exporting/saving model and prediction. Having a difficult time figuring these steps out. Thank you in advance. |
You need to call these methods on your |
raijinspecial - how did you save your model? Would you mind sharing the code for saving and predicting? Thank you guys. |
The following test goes through the full lifecycle of the https://github.com/tensorflow/adanet/blob/v0.3.0/adanet/core/estimator_test.py#L555 You can use it as a reference. |
Thank you for the reference. I'm not a python guru so I'm still struggling to get the code working for prediction and saving. Any way to provide working code after running the "Adanet_objective.ipynb" code? It'd be greatly appreciated for such a great project. Thank you in advance. |
Ok, so I figured out how to make predictions with the regression model. The tutorial example wraps the estimator in the
To train you can just call Predicting was trickier, for me anyway, I'm sure there are cleaner (correct) ways of doing it, this is going to be ugly, but I'm learning - here is what worked for me. To give the model new testing data you have to make a new input function, I borrowed the input_fn given in the tutorial like so:
It says x.values because I was giving it test data from a boston house price test csv from kaggle, converted into a pandas dataframe here called x_test.
This will show you the predictions by printing a dict, if you want the results as an array or series or whatever, extract the dict values:
To check if the predictions were sane I submitted them to the kaggle competition and they scored a 0.16 (I did engineer the training data a bit first rather than use the straight keras.dataset given in the tutorial, i.e, my x_train was (1459, 197)), not bad at all for not optimizing the adanet parameters at all, beyond the very small tweaks you can see in the above code to learning rate and lambda. Predicting on classification is up next. As to exporting the model, I could export the pb file only with the classification model so far and im not sure its right so I dont want to mislead anyone, I'll report when I'm sure I can get it working. GL |
Thank you for sharing. Please keep it coming. This really helps. |
Sorry for a dumb question. I just use : estimator.RunConfig(model_dir="./model_ada") to get the ckpt model and some events, but how to use the final ckpt model to test? where can I get the final learned overall architecture? Thank you very much! |
I found some hints at: https://adanet.readthedocs.io/en/v0.5.0/adanet.html. Look at: export_saved_model(export_dir_base, serving_input_receiver_fn, assets_extra=None, as_text=False, checkpoint_path=None) It seems similar to: https://www.tensorflow.org/api_docs/python/tf/estimator/Estimator#export_saved_model What I did: First I changed def train_and_evaluate, that it will return the estimator:
And then I tried to export/save the estimator:
It will save but I still have to change the tf.constant to a real input. I hope this will help a little bit. |
How-to question: I've been testing and learning with the "adanet_objective" sample. How do you use the recommended model to run predictions samples and eventually serve for live data feed?
The text was updated successfully, but these errors were encountered: