คำเตือน: API นี้เลิกใช้แล้วและจะถูกลบออกใน TensorFlow เวอร์ชันอนาคตหลังจากที่ การแทนที่ มีเสถียรภาพ
SavedModelBundle
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
SavedModelBundle แสดงถึงโมเดลที่โหลดจากที่จัดเก็บข้อมูล
โมเดลประกอบด้วยคำอธิบายของการคำนวณ ( Graph
) Session
ที่มีเทนเซอร์ (เช่น พารามิเตอร์หรือตัวแปรในกราฟ) กำหนดค่าเริ่มต้นเป็นค่าที่บันทึกไว้ในที่จัดเก็บ และคำอธิบายของโมเดล (การแสดงแบบอนุกรมของ บัฟเฟอร์โปรโตคอล MetaGraphDef ).
วิธีการสืบทอด
จากคลาส java.lang.Object บูลีน | เท่ากับ (วัตถุ arg0) |
คลาสสุดท้าย<?> | รับคลาส () |
ภายใน | แฮชโค้ด () |
โมฆะสุดท้าย | แจ้ง () |
โมฆะสุดท้าย | แจ้งทั้งหมด () |
สตริง | toString () |
โมฆะสุดท้าย | รอสักครู่ (ยาว arg0, int arg1) |
โมฆะสุดท้าย | รอ (ยาว arg0) |
โมฆะสุดท้าย | รอ () |
จากอินเทอร์เฟซ java.lang.AutoCloseable ความว่างเปล่าที่เป็นนามธรรม | ปิด () |
วิธีการสาธารณะ
โมฆะสาธารณะ ปิด ()
เผยแพร่ทรัพยากร ( Graph
และ Session
) ที่เกี่ยวข้องกับบันเดิลโมเดลที่บันทึกไว้
กราฟ กราฟ สาธารณะ ()
ส่งกลับกราฟที่อธิบายการคำนวณที่ทำโดยแบบจำลอง
โหลดโมเดลที่บันทึกไว้จากไดเร็กทอรีการส่งออก ควรสร้างโมเดลที่กำลังโหลดโดยใช้ Saved Model API
วิธีนี้เป็นชวเลขสำหรับ:
SavedModelBundle.loader().withTags(tags).load();
พารามิเตอร์
ส่งออกDir | เส้นทางไดเร็กทอรีที่มีโมเดลที่บันทึกไว้ |
---|
แท็ก | แท็กที่ระบุ metagraphdef เฉพาะที่จะโหลด |
---|
การส่งคืน
- กลุ่มที่มีกราฟและเซสชันที่เกี่ยวข้อง
โหลดโมเดลที่บันทึกไว้
ส่งคืนออบเจ็กต์
Loader
ที่สามารถตั้งค่าตัวเลือกการกำหนดค่าก่อนที่จะโหลดโมเดลจริง
พารามิเตอร์
ส่งออกDir | เส้นทางไดเร็กทอรีที่มีโมเดลที่บันทึกไว้ |
---|
เซ สชั่น สาธารณะ ()
ส่งคืน Session
ที่จะดำเนินการคำนวณโดยใช้โมเดล
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 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"]]