Answers.Body: <p><strong>Answer to Question 1</strong></p>
  <p>TensorFlow's <a href="https://www.tensorflow.org/api_docs/python/tf/keras/saving/save_model#:%7E:text=With%20save_format%3D%22tf%22%20%2C,are%20included%20in%20the%20SavedModel." rel="nofollow noreferrer">documentation</a> provides the following information on what is saved:</p>
  <blockquote>
  <p>The model config, weights, and optimizer are included in the SavedModel. Additionally, for every Keras layer attached to the model, the SavedModel stores:</p>
  <ul>
  <li>The config and metadata -- e.g. name, dtype, trainable status</li>
  <li>Traced call and loss functions, which are stored as TensorFlow subgraphs.</li>
  </ul>
  </blockquote>
  <p>You can use <a href="https://www.tensorflow.org/tensorboard/graphs#:%7E:text=TensorBoard%27s%20Graphs%20dashboard%20is%20a,how%20TensorFlow%20understands%20your%20program." rel="nofollow noreferrer">TensorBoard's Graphs dashboard</a> to visualize your model.</p>
  <p>For a quick dive watch <a href="https://youtu.be/Uzkhn5ENJzQ?t=434" rel="nofollow noreferrer">Tensorboard with Tensorflow 2.0 under 10 mins</a>.</p>
  <p><strong>Answer to Question 2</strong></p>
  <p>See jdehesa's answer to a similar question regarding TF and H5 files: <a href="https://stackoverflow.com/questions/61006270/what-is-the-difference-between-pb-savedmodel-and-tf-savedmodel">What is the difference between .pb SavedModel and .tf</a></p>
  <p><strong>Answer to Question 3</strong></p>
  <p>Yes. Both formats, .pb and .tf, are used to save meaningful data and are used for reading in the models.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-20T02:46:07.757Z
Answers.Text: 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.
Answers.UserDisplayName: Ryan Wang
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-19T04:11:29.553Z
Answers.LastActivityDate: 2023-06-19T04:18:45.103Z
Answers.LastEditDate: 2023-06-19T04:18:45.103Z
Answers.UserDisplayName: Brian O'Donnell
Body: <p>I'm building a feature for my application that requires <strong>reading the properties of a saved ML model file</strong> (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 <code>Savedmodel</code> file or a <code>h5</code> file.</p>
  <p>My questions are:</p>
  <ol>
  <li>What is actually being saved in those files typically? And what does it look like?</li>
  <li>Is it a big difference when you save your model differently? for example <code>h5</code> vs <code>savedmodel</code> or tensorflow vs pytorch.</li>
  <li>Is it possible for me to read meaningful information from any saved files regardless of the format? <em>So it doesn't matter if someone else used Pytorch, Tensorflow, or C to do ML</em></li>
  </ol>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-06-20T11:49:40.087Z
Comments.Text: 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.
Comments.UserDisplayName: nbro
Tags: <machine-learning><tensorflow><pytorch><models><weights>
Title: What is actually being saved in the file when you save a model? For example a Tensorflow SavedModel file
UserDisplayName: Ryan Wang
ThreadText: # What is actually being saved in the file when you save a model? For example a Tensorflow SavedModel file
  
  (Asked by: username_0 on 2023-06-19)
  
  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*
  
  **Tags:** machine-learning, tensorflow, pytorch, models, weights
  
  > **Comments:**
  > **username_1**: 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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-06-19. Score: 3
  
  **Answer to Question 1**
  
  TensorFlow's [documentation](https://www.tensorflow.org/api_docs/python/tf/keras/saving/save_model#:%7E:text=With%20save_format%3D%22tf%22%20%2C,are%20included%20in%20the%20SavedModel.) 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](https://www.tensorflow.org/tensorboard/graphs#:%7E:text=TensorBoard%27s%20Graphs%20dashboard%20is%20a,how%20TensorFlow%20understands%20your%20program.) to visualize your model.
  
  For a quick dive watch [Tensorboard with Tensorflow 2.0 under 10 mins](https://youtu.be/Uzkhn5ENJzQ?t=434).
  
  **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](https://stackoverflow.com/questions/61006270/what-is-the-difference-between-pb-savedmodel-and-tf-savedmodel)
  
  **Answer to Question 3**
  
  Yes. Both formats, .pb and .tf, are used to save meaningful data and are used for reading in the models.
  
  > **Comments:**
  > **username_0**: 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.  
  
  ---
  
  