-
Notifications
You must be signed in to change notification settings - Fork 82
Models
Wiki ▸ Models
A model is a self-contained TensorFlow graph with associated data and well-defined run methods. To use a TensorFlow model in a Flink program, define a class representing the model based on one of the below options.
A saved model is one based on the canonical TensorFlow export format called SavedModel format. Using a TensorFlow API available in Python, you export a trained model including its graph, variable data, and some metadata about the expected inputs and outputs. More information:
Once you've exported the model, you'll write a Scala class representing the model to use it in a Flink program. The class to extend is called TensorFlowModel
. See HalfPlusTwo
for an example.
A generic model is one based on a graph loaded from storage or generated from scratch. See ImageNormalization
for an example.
A model exposes well-defined methods to interact with it, such as performing a classification or regression, called graph methods. A graph method specifies the inputs and outputs for the interaction, in terms of input and output tensors. This makes it easier to convert your program data into a format understood by TensorFlow.
You'll write a Scala class representing each graph method that your model supports. Extend GraphMethod
and specify the type information for the input and output. See RegressionMethod
for example.
Each method exposed by a model has a name, an associated graph method, and a signature definition (SignatureDef) that binds the graph method to a specific graph. Together these are referred to as a model function. In your model class, expose one or more model functions using the ModelFunction
class. See ImageNormalization
for an example.
For SavedModels, the SignatureDef is stored in the exported file. For generic models, the SignatureDef is ad-hoc.
Getting Started
Reference
Examples