L'exemple LabelImage démontre l'utilisation de cette API pour classer des images à l'aide d'un réseau neuronal convolutif d'architecture Inception pré-entraîné. Ça démontre:
Construction de graphique : utilisation de la classe OperationBuilder pour construire un graphique afin de décoder, redimensionner et normaliser une image JPEG.
Chargement du modèle : utilisation de Graph.importGraphDef() pour charger un modèle Inception pré-entraîné.
Exécution de graphiques : utilisation d'une session pour exécuter les graphiques et trouver la meilleure étiquette pour une image.
Des exemples supplémentaires peuvent être trouvés dans le référentiel tensorflow/java GitHub.
Utilisé pour instancier une classe abstraite qui remplace la méthode buildSubgraph pour créer un sous-graphe conditionnel ou corporel pour une boucle while.
Contrôle comment agir lorsque nous essayons d'exécuter une opération sur un appareil donné mais que certains tenseurs d'entrée ne sont pas sur cet appareil.
Exception non cochée levée lors de l'exécution de TensorFlow Graphs.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées. Une partie du contenu fait l'objet d'une licence Numpy.
Dernière mise à jour le 2025/07/28 (UTC).
[null,null,["Dernière mise à jour le 2025/07/28 (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](/versions/r2.9/api_docs/java/org/tensorflow/ExecutionEnvironment) | Defines an environment for creating and executing TensorFlow [Operation](/versions/r2.9/api_docs/java/org/tensorflow/Operation)s. |\n| [Graph.WhileSubgraphBuilder](/versions/r2.9/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](/versions/r2.9/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e | Interface implemented by operands of a TensorFlow operation. |\n| [Operation](/versions/r2.9/api_docs/java/org/tensorflow/Operation) | Performs computation on Tensors. |\n| [OperationBuilder](/versions/r2.9/api_docs/java/org/tensorflow/OperationBuilder) | A builder for [Operation](/versions/r2.9/api_docs/java/org/tensorflow/Operation)s. |\n\n### Classes\n\n|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [EagerSession](/versions/r2.9/api_docs/java/org/tensorflow/EagerSession) | An environment for executing TensorFlow operations eagerly. |\n| [EagerSession.Options](/versions/r2.9/api_docs/java/org/tensorflow/EagerSession.Options) | |\n| [Graph](/versions/r2.9/api_docs/java/org/tensorflow/Graph) | A data flow graph representing a TensorFlow computation. |\n| [GraphOperation](/versions/r2.9/api_docs/java/org/tensorflow/GraphOperation) | Implementation for an [Operation](/versions/r2.9/api_docs/java/org/tensorflow/Operation) added as a node to a [Graph](/versions/r2.9/api_docs/java/org/tensorflow/Graph). |\n| [GraphOperationBuilder](/versions/r2.9/api_docs/java/org/tensorflow/GraphOperationBuilder) | An [OperationBuilder](/versions/r2.9/api_docs/java/org/tensorflow/OperationBuilder) for adding [GraphOperation](/versions/r2.9/api_docs/java/org/tensorflow/GraphOperation)s to a [Graph](/versions/r2.9/api_docs/java/org/tensorflow/Graph). |\n| [Output](/versions/r2.9/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | A symbolic handle to a tensor produced by an [Operation](/versions/r2.9/api_docs/java/org/tensorflow/Operation). |\n| [SavedModelBundle](/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle) | SavedModelBundle represents a model loaded from storage. |\n| [SavedModelBundle.Loader](/versions/r2.9/api_docs/java/org/tensorflow/SavedModelBundle.Loader) | Options for loading a SavedModel. |\n| [Server](/versions/r2.9/api_docs/java/org/tensorflow/Server) | An in-process TensorFlow server, for use in distributed training. |\n| [Session](/versions/r2.9/api_docs/java/org/tensorflow/Session) | Driver for [Graph](/versions/r2.9/api_docs/java/org/tensorflow/Graph) execution. |\n| [Session.Run](/versions/r2.9/api_docs/java/org/tensorflow/Session.Run) | Output tensors and metadata obtained when executing a session. |\n| [Session.Runner](/versions/r2.9/api_docs/java/org/tensorflow/Session.Runner) | Run [Operation](/versions/r2.9/api_docs/java/org/tensorflow/Operation)s and evaluate [Tensors](/versions/r2.9/api_docs/java/org/tensorflow/Tensor). |\n| [Shape](/versions/r2.9/api_docs/java/org/tensorflow/Shape) | The possibly partially known shape of a tensor produced by an operation. |\n| [Tensor](/versions/r2.9/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](/versions/r2.9/api_docs/java/org/tensorflow/TensorFlow) | Static utility methods describing the TensorFlow runtime. |\n| [Tensors](/versions/r2.9/api_docs/java/org/tensorflow/Tensors) | Type-safe factory methods for creating [Tensor](/versions/r2.9/api_docs/java/org/tensorflow/Tensor) objects. |\n\n### Enums\n\n|--------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|\n| [DataType](/versions/r2.9/api_docs/java/org/tensorflow/DataType) | Represents the type of elements in a [Tensor](/versions/r2.9/api_docs/java/org/tensorflow/Tensor) as an enum. |\n| [EagerSession.DevicePlacementPolicy](/versions/r2.9/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](/versions/r2.9/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](/versions/r2.9/api_docs/java/org/tensorflow/TensorFlowException) | Unchecked exception thrown when executing TensorFlow Graphs. |"]]