> For the complete documentation index, see [llms.txt](https://huang-jason.gitbook.io/deep/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huang-jason.gitbook.io/deep/save-and-restore.md).

# Save & restore

<https://medium.com/@jsflo.dev/saving-and-loading-a-tensorflow-model-using-the-savedmodel-api-17645576527>

```python
assets/
assets.extra/
variables/ #  learned weights
    variables.data-*****-of-*****
    variables.index
saved_model.pb # graph structure
```

## tf.train.Saver

```python
# construct graph!
...
# add save/restore ops
saver = tf.train.Saver()
...
# save after training
save_path = saver.save(sess, "/tmp/model.ckpt")
```

you need to reconstruct graph to restore.

Use case = splitting training into separate sessions and want a quick way to resume training.

## tf.saved\_model.simple\_save

```python
simple_save(sess,
            export_dir,
            inputs={"myInput": x},
            outputs={"myOutput": y})
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huang-jason.gitbook.io/deep/save-and-restore.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
