Distinguish types of on-disk models

你。 提交于 2019-12-31 04:39:10

问题


Tensorflow has several types of model formats:

  1. 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 the pb 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 the pb 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 word frozen 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 no ckpt 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!