TensorFlow: How do I release a model without source code?

后端 未结 2 1938
栀梦
栀梦 2020-12-21 11:42

I am using Tensorflow + Python.

I am curious if I can release a saved Tensorflow model (architecture + trained variables) without detailed source code. I\'m aware of

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 11:57

    You can build a Saver from the MetaGraphDef (saved with checkpoints by default: those .meta files). and then use that Saver to restore your model. So users don't have to re-define your graph in their code. But then they still need to figure out the model signature (input, output variables). I solve this using tf.Collection (but i am interested to find better ways to do it as well).

    You can take a look at my example implementation (the eval.py evaluate a model without re-defining a model):

    • reconstruct saver from meta graph https://github.com/falcondai/cifar10/blob/master/eval.py#L18
    • get input variables from collections https://github.com/falcondai/cifar10/blob/master/eval.py#L58
    • how to define your model https://github.com/falcondai/cifar10/blob/master/models/cp2f3d.py

提交回复
热议问题