Skip to content

Instantly share code, notes, and snippets.

@helinwang
Last active December 11, 2016 16:27
Show Gist options
  • Save helinwang/7782c6b2815c334c77653fc0e52b6069 to your computer and use it in GitHub Desktop.
Save helinwang/7782c6b2815c334c77653fc0e52b6069 to your computer and use it in GitHub Desktop.
save and load tensorflow tensors using tensorflow golang api
// Save:
outTensor, err := tf.NewTensor(filename)
if err != nil {
return err
}
_, err = session.Run(
map[tf.Output]*tf.Tensor{
graph.Operation("save/Const").Output(0): outTensor,
},
nil,
[]*tf.Operation{
graph.Operation("save/SaveV2"),
},
)
// Load:
outTensor, err := tf.NewTensor(filename)
if err != nil {
return err
}
_, err = session.Run(
map[tf.Output]*tf.Tensor{
graph.Operation("save/Const").Output(0): outTensor,
},
nil,
[]*tf.Operation{
graph.Operation("save/restore_all"),
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment