问题
Tensorflow has several types of model formats:
- TensorFlow SavedModel 2. Frozen Model 3. Session Bundle 4. Tensorflow Hub module
How can you distinguish between them on-disk? (to later use with tensorflowjs-converter)
And how is each model created?
回答1:
Yup, there are a LOT of different model types, and they all have good reasons. I'm not going to claim that I have perfect clarity of each, but here's what I know (I think I know).
- The
.pb
file: PB stands for protobuff or Protocol Buffer. This is the model structure, generally without the trained weights and is stored in a binary format. - The
.pbtxt
file: Nonbinary of thepb
file for human reading. - Protobuff files that aren't frozen will need a checkpoint
.ckpt
file, too. The Checkpoint file is the missing set of weights that thepb
needs. - The
.h5
file: The model + weights from a Keras save - The
.tflite
file would be a TensorflowLite model - Frozen Model: A frozen model combines the
pb
with the weights file, so you don't have to manage two of them. Usually, this means adding the wordfrozen
to the filename. I'm sure this can be inferred when loading the file, but on disk they are a bit more on the honor system and nockpt
file. This strips out extraneous graph info; it's basically like the "Production Ready" version of the model. - Session Bundle: Are a directory. They are nolonger used, and rare.
- Tensorflow Hub Module: These are pre-existing popular models that are very likely already exported to TFJS and don't require you to manually convert them. I assume they are supported for Google's benefit, more so than ours. But it's nice to know if you use hub, you can always convert it.
A multi-exported grouping of files looks like this image. From here, you can see quite a few that you could turn into TFJS.
来源:https://stackoverflow.com/questions/56340852/distinguish-types-of-on-disk-models