Cảnh báo: API này không được dùng nữa và sẽ bị xóa trong phiên bản tương lai của TensorFlow sau khi thay thế ổn định.
SavedModelBundle
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
SavingModelBundle đại diện cho một mô hình được tải từ bộ lưu trữ.
Mô hình bao gồm mô tả tính toán ( Graph
), Session
có các tensor (ví dụ: tham số hoặc biến trong biểu đồ) được khởi tạo cho các giá trị được lưu trong bộ lưu trữ và mô tả mô hình (biểu diễn tuần tự của bộ đệm giao thức MetaGraphDef ).
Phương pháp kế thừa
Từ lớp java.lang.Object boolean | bằng (Đối tượng arg0) |
Lớp cuối cùng<?> | getClass () |
int | mã băm () |
khoảng trống cuối cùng | thông báo () |
khoảng trống cuối cùng | thông báoTất cả () |
Sợi dây | toString () |
khoảng trống cuối cùng | chờ đã (arg0 dài, int arg1) |
khoảng trống cuối cùng | chờ đã (arg0 dài) |
khoảng trống cuối cùng | Chờ đợi () |
Từ giao diện java.lang.AutoCloseable khoảng trống trừu tượng | đóng () |
Phương pháp công khai
đóng khoảng trống công khai ()
Phát hành các tài nguyên ( Graph
và Session
) được liên kết với gói mô hình đã lưu.
biểu đồ đồ thị công khai ()
Trả về biểu đồ mô tả tính toán được thực hiện bởi mô hình.
Tải mô hình đã lưu từ thư mục xuất. Mô hình đang được tải phải được tạo bằng API mô hình đã lưu .
Phương pháp này là viết tắt của:
SavedModelBundle.loader().withTags(tags).load();
Thông số
xuấtDir | đường dẫn thư mục chứa mô hình đã lưu. |
---|
thẻ | các thẻ xác định metagraphdef cụ thể để tải. |
---|
Trả lại
- một gói chứa biểu đồ và phiên liên quan.
Tải một mô hình đã lưu.
Trả về một đối tượng
Loader
có thể đặt các tùy chọn cấu hình trước khi thực sự tải mô hình,
Thông số
xuấtDir | đường dẫn thư mục chứa mô hình đã lưu. |
---|
phiên phiên công khai ()
Trả về Session
để thực hiện tính toán bằng mô hình.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["# SavedModelBundle\n\npublic class **SavedModelBundle** \nSavedModelBundle represents a model loaded from storage.\n\nThe model consists of a description of the computation (a [Graph](/api_docs/java/org/tensorflow/Graph)), a [Session](/api_docs/java/org/tensorflow/Session)\nwith tensors (e.g., parameters or variables in the graph) initialized to values saved in storage,\nand a description of the model (a serialized representation of a [MetaGraphDef\nprotocol buffer](https://www.tensorflow.org/code/tensorflow/core/protobuf/meta_graph.proto)).\n\n\u003cbr /\u003e\n\n### Nested Classes\n\n|-------|---|---|-----------------------------------|\n| class | [SavedModelBundle.Loader](/api_docs/java/org/tensorflow/SavedModelBundle.Loader) || Options for loading a SavedModel. |\n\n### Public Methods\n\n|-----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [close](/api_docs/java/org/tensorflow/SavedModelBundle#close())() Releases resources (the [Graph](/api_docs/java/org/tensorflow/Graph) and [Session](/api_docs/java/org/tensorflow/Session)) associated with the saved model bundle. |\n| [Graph](/api_docs/java/org/tensorflow/Graph) | [graph](/api_docs/java/org/tensorflow/SavedModelBundle#graph())() Returns the graph that describes the computation performed by the model. |\n| static [SavedModelBundle](/api_docs/java/org/tensorflow/SavedModelBundle) | [load](/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. |\n| static [SavedModelBundle.Loader](/api_docs/java/org/tensorflow/SavedModelBundle.Loader) | [loader](/api_docs/java/org/tensorflow/SavedModelBundle#loader(java.lang.String))(String exportDir) Load a saved model. |\n| byte\\[\\] | [metaGraphDef](/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. |\n| [Session](/api_docs/java/org/tensorflow/Session) | [session](/api_docs/java/org/tensorflow/SavedModelBundle#session())() Returns the [Session](/api_docs/java/org/tensorflow/Session) with which to perform computation using the model. |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFrom interface java.lang.AutoCloseable \n\n|---------------|---------|\n| abstract void | close() |\n\nPublic Methods\n--------------\n\n#### public void\n**close**\n()\n\nReleases resources (the [Graph](/api_docs/java/org/tensorflow/Graph) and [Session](/api_docs/java/org/tensorflow/Session)) associated with the saved model\nbundle. \n\n#### public [Graph](/api_docs/java/org/tensorflow/Graph)\n**graph**\n()\n\nReturns the graph that describes the computation performed by the model. \n\n#### public static [SavedModelBundle](/api_docs/java/org/tensorflow/SavedModelBundle)\n**load**\n(String exportDir, String... tags)\n\nLoad a saved model from an export directory. The model that is being loaded should be created\nusing the [Saved Model\nAPI](https://www.tensorflow.org/api_docs/python/tf/saved_model).\n\nThis method is a shorthand for:\n\n SavedModelBundle.loader().withTags(tags).load();\n \n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| exportDir | the directory path containing a saved model. |\n| tags | the tags identifying the specific metagraphdef to load. |\n|-----------|---------------------------------------------------------|\n\n##### Returns\n\n- a bundle containing the graph and associated session. \n\n#### public static [SavedModelBundle.Loader](/api_docs/java/org/tensorflow/SavedModelBundle.Loader)\n**loader**\n(String exportDir)\n\nLoad a saved model.\n\n\u003cbr /\u003e\n\nReturns a `Loader` object that can set configuration options before actually loading the model,\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| exportDir | the directory path containing a saved model. |\n|-----------|----------------------------------------------|\n\n#### public byte\\[\\]\n**metaGraphDef**\n()\n\nReturns the serialized [MetaGraphDef\nprotocol buffer](https://www.tensorflow.org/code/tensorflow/core/protobuf/meta_graph.proto) associated with the saved model. \n\n#### public [Session](/api_docs/java/org/tensorflow/Session)\n**session**\n()\n\nReturns the [Session](/api_docs/java/org/tensorflow/Session) with which to perform computation using the model. \n\n##### Returns\n\n- the initialized session"]]