Ví dụ về LabelImage thể hiện việc sử dụng API này để phân loại hình ảnh bằng cách sử dụng mạng thần kinh tích chập kiến trúc Inception được đào tạo trước. Nó thể hiện:
Xây dựng biểu đồ: sử dụng lớp OperationBuilder để xây dựng biểu đồ nhằm giải mã, thay đổi kích thước và chuẩn hóa hình ảnh JPEG.
Tải mô hình: Sử dụng Graph.importGraphDef() để tải mô hình Khởi động được đào tạo trước.
Thực thi biểu đồ: Sử dụng Phiên để thực thi biểu đồ và tìm nhãn tốt nhất cho hình ảnh.
Các ví dụ bổ sung có thể được tìm thấy trong kho lưu trữ tensorflow/java GitHub.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[],[],null,["# org.tensorflow\n\nDefines classes to build, save, load and execute TensorFlow models. **Warning:** This API is deprecated and will be removed in a future version of TensorFlow after [the replacement](https://tensorflow.org/java) is stable.\n\nTo get started, see the [installation instructions.](https://tensorflow.org/install/lang_java_legacy)\n\nThe [LabelImage](https://www.tensorflow.org/code/tensorflow/java/src/main/java/org/tensorflow/examples/LabelImage.java)\nexample demonstrates use of this API to classify images using a pre-trained [Inception](http://arxiv.org/abs/1512.00567) architecture convolutional neural network.\nIt demonstrates:\n\n- Graph construction: using the OperationBuilder class to construct a graph to decode, resize and normalize a JPEG image.\n- Model loading: Using Graph.importGraphDef() to load a pre-trained Inception model.\n- Graph execution: Using a Session to execute the graphs and find the best label for an image.\n\nAdditional examples can be found in the [tensorflow/java](https://github.com/tensorflow/java) GitHub repository.\n\n\u003cbr /\u003e\n\n### Interfaces\n\n|----------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n| [ExecutionEnvironment](/api_docs/java/org/tensorflow/ExecutionEnvironment) | Defines an environment for creating and executing TensorFlow [Operation](/api_docs/java/org/tensorflow/Operation)s. |\n| [Graph.WhileSubgraphBuilder](/api_docs/java/org/tensorflow/Graph.WhileSubgraphBuilder) | Used to instantiate an abstract class which overrides the buildSubgraph method to build a conditional or body subgraph for a while loop. |\n| [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e | Interface implemented by operands of a TensorFlow operation. |\n| [Operation](/api_docs/java/org/tensorflow/Operation) | Performs computation on Tensors. |\n| [OperationBuilder](/api_docs/java/org/tensorflow/OperationBuilder) | A builder for [Operation](/api_docs/java/org/tensorflow/Operation)s. |\n\n### Classes\n\n|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [EagerSession](/api_docs/java/org/tensorflow/EagerSession) | An environment for executing TensorFlow operations eagerly. |\n| [EagerSession.Options](/api_docs/java/org/tensorflow/EagerSession.Options) | |\n| [Graph](/api_docs/java/org/tensorflow/Graph) | A data flow graph representing a TensorFlow computation. |\n| [GraphOperation](/api_docs/java/org/tensorflow/GraphOperation) | Implementation for an [Operation](/api_docs/java/org/tensorflow/Operation) added as a node to a [Graph](/api_docs/java/org/tensorflow/Graph). |\n| [GraphOperationBuilder](/api_docs/java/org/tensorflow/GraphOperationBuilder) | An [OperationBuilder](/api_docs/java/org/tensorflow/OperationBuilder) for adding [GraphOperation](/api_docs/java/org/tensorflow/GraphOperation)s to a [Graph](/api_docs/java/org/tensorflow/Graph). |\n| [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | A symbolic handle to a tensor produced by an [Operation](/api_docs/java/org/tensorflow/Operation). |\n| [SavedModelBundle](/api_docs/java/org/tensorflow/SavedModelBundle) | SavedModelBundle represents a model loaded from storage. |\n| [SavedModelBundle.Loader](/api_docs/java/org/tensorflow/SavedModelBundle.Loader) | Options for loading a SavedModel. |\n| [Server](/api_docs/java/org/tensorflow/Server) | An in-process TensorFlow server, for use in distributed training. |\n| [Session](/api_docs/java/org/tensorflow/Session) | Driver for [Graph](/api_docs/java/org/tensorflow/Graph) execution. |\n| [Session.Run](/api_docs/java/org/tensorflow/Session.Run) | Output tensors and metadata obtained when executing a session. |\n| [Session.Runner](/api_docs/java/org/tensorflow/Session.Runner) | Run [Operation](/api_docs/java/org/tensorflow/Operation)s and evaluate [Tensors](/api_docs/java/org/tensorflow/Tensor). |\n| [Shape](/api_docs/java/org/tensorflow/Shape) | The possibly partially known shape of a tensor produced by an operation. |\n| [Tensor](/api_docs/java/org/tensorflow/Tensor)\\\u003cT\\\u003e | A statically typed multi-dimensional array whose elements are of a type described by T. |\n| [TensorFlow](/api_docs/java/org/tensorflow/TensorFlow) | Static utility methods describing the TensorFlow runtime. |\n| [Tensors](/api_docs/java/org/tensorflow/Tensors) | Type-safe factory methods for creating [Tensor](/api_docs/java/org/tensorflow/Tensor) objects. |\n\n### Enums\n\n|------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|\n| [DataType](/api_docs/java/org/tensorflow/DataType) | Represents the type of elements in a [Tensor](/api_docs/java/org/tensorflow/Tensor) as an enum. |\n| [EagerSession.DevicePlacementPolicy](/api_docs/java/org/tensorflow/EagerSession.DevicePlacementPolicy) | Controls how to act when we try to run an operation on a given device but some input tensors are not on that device. |\n| [EagerSession.ResourceCleanupStrategy](/api_docs/java/org/tensorflow/EagerSession.ResourceCleanupStrategy) | Controls how TensorFlow resources are cleaned up when they are no longer needed. |\n\n### Exceptions\n\n|--------------------------------------------------------------------------|--------------------------------------------------------------|\n| [TensorFlowException](/api_docs/java/org/tensorflow/TensorFlowException) | Unchecked exception thrown when executing TensorFlow Graphs. |"]]