I have build RNN
model in tensor-flow
based on reddit/twitter conversations. I saved it in pb
. Does anyone know how to pass raw text string through the model in golang
and produce output?
modeldir := "/my_model.pb"
// Buffer input text
var buffer bytes.Buffer
args := os.Args[1:]
for _, arg := range args {
buffer.WriteString(arg + " ")
}
inputText := buffer.String()
// Load the serialized GraphDef from a file.
model, err := ioutil.ReadFile(modeldir)
if err != nil {
log.Fatal(err)
}
// Construct an in-memory graph from the serialized form.
graph := tf.NewGraph()
if err := graph.Import(model, ""); err != nil {
log.Fatal(err)
}
// Create a session for inference over graph.
session, err := tf.NewSession(graph, nil)
if err != nil {
log.Fatal(err)
}
defer session.Close()