# SavedModelBundle

public class **SavedModelBundle** SavedModelBundle represents a model loaded from storage.

The model consists of a description of the computation (a `https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Graph`), a `https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Session`
with tensors (e.g., parameters or variables in the graph) initialized to values saved in storage,
and a description of the model (a serialized representation of a [MetaGraphDef
protocol buffer](https://www.tensorflow.org/code/tensorflow/core/protobuf/meta_graph.proto)).

<br />

### Nested Classes

|---|---|---|---|
| class | [SavedModelBundle.Loader](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle.Loader) || Options for loading a SavedModel. |

### Public Methods

|---|---|
| void | [close](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle#close())() Releases resources (the `https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Graph` and `https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Session`) associated with the saved model bundle. |
| [Graph](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Graph) | [graph](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle#graph())() Returns the graph that describes the computation performed by the model. |
| static [SavedModelBundle](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle) | [load](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle#load(java.lang.String,%20java.lang.String...))(String exportDir, String... tags) Load a saved model from an export directory. |
| static [SavedModelBundle.Loader](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle.Loader) | [loader](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle#loader(java.lang.String))(String exportDir) Load a saved model. |
| byte\[\] | [metaGraphDef](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle#metaGraphDef())() Returns the serialized [MetaGraphDef protocol buffer](https://www.tensorflow.org/code/tensorflow/core/protobuf/meta_graph.proto) associated with the saved model. |
| [Session](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Session) | [session](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle#session())() Returns the `https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Session` with which to perform computation using the model. |

### Inherited Methods

From class java.lang.Object

|---|---|
| boolean | equals(Object arg0) |
| final Class\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| String | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

From interface java.lang.AutoCloseable

|---|---|
| abstract void | close() |

## Public Methods

#### public void
**close**
()

Releases resources (the `https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Graph` and `https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Session`) associated with the saved model
bundle.

#### public [Graph](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Graph)
**graph**
()

Returns the graph that describes the computation performed by the model.

#### public static [SavedModelBundle](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle)
**load**
(String exportDir, String... tags)

Load a saved model from an export directory. The model that is being loaded should be created
using the [Saved Model
API](https://www.tensorflow.org/api_docs/python/tf/saved_model).

This method is a shorthand for:

    SavedModelBundle.loader().withTags(tags).load();
     
<br />

<br />

##### Parameters

| exportDir | the directory path containing a saved model. |
| tags | the tags identifying the specific metagraphdef to load. |
|---|---|

##### Returns

- a bundle containing the graph and associated session.

#### public static [SavedModelBundle.Loader](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle.Loader)
**loader**
(String exportDir)

Load a saved model.

<br />

Returns a `Loader` object that can set configuration options before actually loading the model,

<br />

##### Parameters

| exportDir | the directory path containing a saved model. |
|---|---|

#### public byte\[\]
**metaGraphDef**
()

Returns the serialized [MetaGraphDef
protocol buffer](https://www.tensorflow.org/code/tensorflow/core/protobuf/meta_graph.proto) associated with the saved model.

#### public [Session](https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Session)
**session**
()

Returns the `https://www.tensorflow.org/versions/r2.9/api_docs/java/org/tensorflow/Session` with which to perform computation using the model.

##### Returns

- the initialized session