Reputation: 68
Is it possible to convert a graph model into a layers model? The official TensorFlow js converter (https://github.com/tensorflow/tfjs/tree/master/tfjs-converter) does not support this feature at the moment or are there reasons that cannot work?
Upvotes: 4
Views: 1517
Reputation: 28472
The layers model format supports fewer features than the SavedModel and graph model formats, so you cannot convert layers to graph. However, I have not seen the opposite conversion take place either.
When referring to the function which loads a graph model, tf.loadGraphModel
:
The loaded model only supports only inference, but the speed of inference is generally faster than that of a tfjs_layers_model source
When referring to the function which loads a layers model, tf.loadLayersModel
:
The loaded model supports the full inference and training (e.g., transfer learning) features of the original keras or tf.keras model.
So I would argue the answer is: No, because the conversion library tfjs-converter doesn't support it, probably because the layers format cannot hold the information that a SavedModel or graph model can. Here, I try to summarise the differences between the 2 formats.
Upvotes: 0
Reputation: 18371
tfjs does not support converting a graph layer to a sequential one.
A graph layer gives more abilities to create model that it can't be narrowed to a sequential layer.
"If you can move mountains you can move molehills", so layers models can be converted to graph models. The converter supports converting sequential layers to graph. But obviously the converse is not true
Upvotes: 5