Use JSON instead of protocol buffers in the TensorFlow saved model converter.
There are many situations we want to simply inspect the model topology to debug an issue, however the protocol buffer makes it extremely hard. The protocol buffer also makes us depend on protobufjs, which is a dependency which we should be able to remove.
It would be great to convert the model definition over to JSON (even simply with a toJSON() call on the proto during conversion). We can use a typescript interface for the JSON object on the other side.
This will also give us parity between the Keras / TensorFlow SavedModel worlds.
I am having problems with .pb model while inspecting it.
- I used tfjs-converter to convert the keras frozen graph to javascript format.
- Loaded the model and weights manifest using tf.loadFrozenModel().
- However I am facing difficulties while inspecting it.
Now I need to convert .pb to json and then use the model further? How does toJSON() call work?
cc @pyu10055 for advice on how to inspect the model topology proto.
@pyu10055 could you assist in converting .pb to json. If not, is there any help available regarding using loaded .pb model in tensorflowjs and its inspection.
@Raza25 The model returns from loadFrozenModel() call contains an attribute graph of type GraphExecutor, which has a graph attribution that contains all the nodes of the graph. The kera layer information is lost when saving Keras to graph, but the node name can give you some hints on which variable scope the nodes belong to.
basically
const model = tf.loadFrozenModel(...);
console.log(model.executor.graph.nodes);
Reopening this issue to track actually deleting all the protocol buffer code and removing the dependency before 1.0.