-
-
Notifications
You must be signed in to change notification settings - Fork 155
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 train model with tfgo? #55
Comments
If you're interested in using a model for inference, it's better to train the model in Pyton, export it as a SavedModel and then use it from tfgo. If instead you're interested in training a model with tfgo (but currently we don't support model saving, hence you have to keep it in memory after training and you can't save it on disk), you must export the training graph + model in Python as a SavedModel and use it from tfgo. I wrote an article that explains this process: https://pgaleone.eu/tensorflow/go/2020/11/27/deploy-train-tesorflow-models-in-go-human-activity-recognition/ |
I read through your guide and figured out how to save a model after training in golang. Note that I am using python TF 2.4.1 and github.com/tensorflow/tensorflow v2.0.3+incompatible. It may work on other TF versions and also with tfgo. When I saved a model tensorflow python it had an additional two The first of the two extra outputs, when given a string value E.G. You can just then copy the original saved_model.pb into Thanks for your article, it pointed me in the right direction. |
@CodingBeard thanks for reading the article and for the feedback! I'm not aware of that method of getting the operation name, but your experience can help other readers. Would you be so kind to open a merge request to the blog repo (https://github.com/galeone/galeone.github.io/blob/master/_posts/2020-11-27-deploy-train-tesorflow-models-in-go-human-activity-recognition.md) adding some lines on how to find the node names if you can't find them using It will be a great addition! |
I'm not using tfgo in my project, but with an older version of tensorflow's golang package it looks like this:
It seems the save node is always the first hidden The full example using python TF 2.4.1 and golang tensorflow/tensorflow/go v2.0.3 is as follows: Python:
golang:
Hopefully that makes sense and you can use it for your article, and maybe even add a method to save the model in this repo. |
woah, thanks for sharing! I guess I'm going to extract something from your code for tfgo 😄 |
Hey, I've continued digging and managed to get the human readable graph def of that saved model. Under the hood the save method seems to be using Human readable graph: https://gist.github.com/CodingBeard/769a42d06a9b9d518e69f6c1ae41e45b I got the graph in that format by making use of
You can figure out what's going on under the hood of a StatefulPartitionedCall (which is a just the graph of a tf.function) using that debug string method. |
How can i save a trained model using golang? With the help of tf-go and Mr.CodingBeard 's code, i can train simple machine leanring model in an online scenario and test them by evaluating related performance metric. Could you please give me some insights to save trained model in save_model or checkpoint format. |
i tried to use privided "saver_filename" and "StatefulPartitionedCall_2" but did not work in other self-build models that are similar to Mr.CodingBeard 's gm |
No description provided.
The text was updated successfully, but these errors were encountered: