View source on GitHub
|
Reload a Keras model/layer that was saved via SavedModel / ExportArchive.
Inherits From: Layer, Operation
tf.keras.layers.TFSMLayer(
filepath,
call_endpoint='serve',
call_training_endpoint=None,
trainable=True,
name=None,
dtype=None
)
Example:
model.export("path/to/artifact")
reloaded_layer = TFSMLayer("path/to/artifact")
outputs = reloaded_layer(inputs)
The reloaded object can be used like a regular Keras layer, and supports training/fine-tuning of its trainable weights. Note that the reloaded object retains none of the internal structure or custom methods of the original object -- it's a brand new layer created around the saved function.
Limitations:
- Only call endpoints with a single
inputstensor argument (which may optionally be a dict/tuple/list of tensors) are supported. For endpoints with multiple separate input tensor arguments, consider subclassingTFSMLayerand implementing acall()method with a custom signature. - If you need training-time behavior to differ from inference-time behavior
(i.e. if you need the reloaded object to support a
training=Trueargument in__call__()), make sure that the training-time call function is saved as a standalone endpoint in the artifact, and provide its name to theTFSMLayervia thecall_training_endpointargument.
Methods
from_config
@classmethodfrom_config( config )
Creates a layer from its config.
This method is the reverse of get_config,
capable of instantiating the same layer from the config
dictionary. It does not handle layer connectivity
(handled by Network), nor weights (handled by set_weights).
| Args | |
|---|---|
config
|
A Python dictionary, typically the output of get_config. |
| Returns | |
|---|---|
| A layer instance. |
symbolic_call
symbolic_call(
*args, **kwargs
)
View source on GitHub