TensorFlow¶
The Snowflake ML Model Registry supports models created using TensorFlow (models derived from tensorflow.Module)
and Keras v2 models (keras.Model with Keras version < 3.0.0).
Note
For Keras 3.0.0 or later, use the Keras handler.
The following additional options can be used in the options dictionary when you call log_model:
Option |
Description |
|---|---|
|
A list of the names of the methods available on the model object. TensorFlow models have |
|
The version of the CUDA runtime to be used when deploying to a platform with GPU; defaults to 11.8. If manually set
to |
|
Whether the model expects multiple tensor inputs. Defaults to |
You must specify either the sample_input_data or signatures parameter when logging a TensorFlow model so
that the registry knows the signatures of the target methods.
Note
Keras v2 models can only have one target method.
Note
When using pandas DataFrames (which use float64 by default), ensure your TensorFlow model uses tf.float64
for variables and tf.TensorSpec input signatures to avoid dtype mismatch errors.
Examples¶
These examples assume reg is an instance of snowflake.ml.registry.Registry.
TensorFlow Module¶
The following example demonstrates creating a TensorFlow model by subclassing tf.Module, logging it to the Snowflake ML Model Registry, and running inference.
Keras v2 Sequential Model¶
The following example demonstrates training a Keras v2 sequential model, logging it to the Snowflake ML Model Registry, and running inference.