Tensorflow MLeap Integration
The MLeap Tensorflow transformer is built with a Tensorflow graph file that was saved using the function. When the transformer lazily initializes a Tensorflow sessions on the first request to transform a leap frame. Once the sessions is started, it remains open until the close
method is called on the MLeap Tensorflow transformer.
The data in the LeapFrame should be in the proper format when handed to the Tensorflow transformer, so that the proper conversions to Tensorflow data types occurs. See the Type Conversions section for how converting to Tensorflow types works.
The model is responsible for maintaining the Tensorflow session. It is a Java Closeable
and needs to be closed when the MLeap transformer or other controlling object no longer needs use of the resources. The model will close the Tensorflow sessions when finalized, just in case the user forgets to call this method. The output of the model is a of MLeap Tensor
that contains the outputs in the same order specified by the given shape.
In order to support transformations using Tensorflow with MLeap data types, the following information is needed.
Here is the list of currently-supported Tensorflow data types.
Tensorflow Data Type | MLeap Data Type |
---|---|
DT_BOOLEAN | BooleanType |
DT_STRING | StringType |
DT_INT32 | IntegerType |
DT_INT64 | LongType |
DT_FLOAT | FloatType |
DT_DOUBLE | DoubleType |
Tensor | TensorType |
Because the Swig wrappers do not provide support for all data types, we recommend adding in casting steps to your Tensorflow graph to integrate with MLeap.
Notes
- Unsigned integer types, 8-bit, and 16-bit integers are not supported by the Swig wrappers
- Complex types are not supported by the Swig wrappers
Example
Types
Field | Data Type |
---|---|
double1 | DoubleType() |
tensor1 | TensorType(DoubleType(false)) |
If we run this LeapFrame through a Tensorflow transformer that uses the double1
value to scale the tensor1
value and we specify we want the scaled output tensor, then the output LeapFrame will look like this:
Types
Field | Data Type | Notes |
---|---|---|
double1 | DoubleType() | |
tensor1 | TensorType(DoubleType(false)) | |
raw_tf_tensors | ListType(AnyType(false)) | Raw return types unknown, nulls are not allowed |
output1 | TensorType(DoubleType(false)) | Underlying type known at this point, and reflected in the LeapFrame |