I am looking at Google\'s example on how to deploy and use a pre-trained Tensorflow graph (model) on Android. This example uses a .pb file at:
Here's another take on @Mostafa's answer. A somewhat cleaner way to run the tf.assign ops is to store them in a tf.group. Here's my Python code:
ops = []
for v in tf.trainable_variables():
vc = tf.constant(v.eval())
ops.append(tf.assign(v, vc));
tf.group(*ops, name="assign_trained_variables")
And in C++:
std::vector tmp;
status = session.Run({}, {}, { "assign_trained_variables" }, &tmp);
if (!status.ok()) {
// Handle error
}
This way you have only one named op to run on the C++ side, so you don't have to mess around with iterating over nodes.