Last active
December 11, 2016 16:27
-
-
Save helinwang/7782c6b2815c334c77653fc0e52b6069 to your computer and use it in GitHub Desktop.
save and load tensorflow tensors using tensorflow golang api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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