0
$\begingroup$

I'm building a feature for my application that requires reading the properties of a saved ML model file (after it's trained). However, as I am pretty new to this field, I don't really understand the foundational knowledge about developing AI, only knowing that parameters are trained and saved. I have some experience with the Tensorflow framework, and I know that a model can be saved in either a Savedmodel file or a h5 file.

My questions are:

  1. What is actually being saved in those files typically? And what does it look like?
  2. Is it a big difference when you save your model differently? for example h5 vs savedmodel or tensorflow vs pytorch.
  3. Is it possible for me to read meaningful information from any saved files regardless of the format? So it doesn't matter if someone else used Pytorch, Tensorflow, or C to do ML
$\endgroup$
1
  • $\begingroup$ Your questions seem to be off-topic here. They are mostly programming questions and specific to frameworks. We focus on the theoretical/non-programming aspects of AI. $\endgroup$
    – nbro
    Commented Jun 20, 2023 at 11:49

1 Answer 1

3
$\begingroup$

Answer to Question 1

TensorFlow's documentation provides the following information on what is saved:

The model config, weights, and optimizer are included in the SavedModel. Additionally, for every Keras layer attached to the model, the SavedModel stores:

  • The config and metadata -- e.g. name, dtype, trainable status
  • Traced call and loss functions, which are stored as TensorFlow subgraphs.

You can use TensorBoard's Graphs dashboard to visualize your model.

For a quick dive watch Tensorboard with Tensorflow 2.0 under 10 mins.

Answer to Question 2

See jdehesa's answer to a similar question regarding TF and H5 files: What is the difference between .pb SavedModel and .tf

Answer to Question 3

Yes. Both formats, .pb and .tf, are used to save meaningful data and are used for reading in the models.

$\endgroup$
1
  • $\begingroup$ so based on your answer, is it true that most ML models are saved in a similar architecture that contains model config, weights, and optimizer? Or I think what I really want to ask is, how do I read information from ML model files of any format, regardless if it was trained with Tensorflow or Pytorch. $\endgroup$
    – Ryan Wang
    Commented Jun 20, 2023 at 2:46

Not the answer you're looking for? Browse other questions tagged .