I have a GRU RNN text generation model that I imported as protobuf in Golang.
model, err := tf.LoadSavedModel("poetryModel", []string{"goTag"}, nil)
Similar to the code from this Tensorflow tutorial, I am running a prediction loop:
for len(generated_text) < 1000 {
result, err := model.Session.Run(
map[tf.Output]*tf.Tensor{
model.Graph.Operation("inputLayer_input").Output(0): tensor,
},
[]tf.Output{
model.Graph.Operation("outputLayer/add").Output(0),
},
nil,
)
...}
However, this implementation discards all intermediate states after every loop which results in bad generated text. I tried using Partial Run, but it threw an error at the second Run:
pr, err := model.Session.NewPartialRun(
[]tf.Output{ model.Graph.Operation("inputLayer_input").Output(0), },
[]tf.Output{ model.Graph.Operation("outputLayer/add").Output(0), },
[]*tf.Operation{ model.Graph.Operation("outputLayer/add") },
)
if err != nil {
panic(err)
}
...
result, err := pr.Run(
map[tf.Output]*tf.Tensor{
model.Graph.Operation("inputLayer_input").Output(0): tensor,
},
[]tf.Output{
model.Graph.Operation("outputLayer/add").Output(0),
},
nil,
)
Error running the session with input, err: Must run 'setup' before performing partial runs!
This question is similar to this one, but in Python. Also, there is no documentation of a setup function in Go. I am new to working directly with the TF computation graph and Golang, so any help is appreciated.