|View source on GitHub|
Represents a file asset to hermetically include in a SavedModel.
Compat aliases for migration
See Migration guide for more details.
tf.saved_model.Asset( path )
Used in the notebooks
|Used in the guide|
A SavedModel can include arbitrary files, called assets, that are needed for its use. For example a vocabulary file used initialize a lookup table.
When a trackable object is exported via
tf.saved_model.save(), all the
Assets reachable from it are copied into the SavedModel assets directory.
Upon loading, the assets and the serialized functions that depend on them
will refer to the correct filepaths inside the SavedModel directory.
filename = tf.saved_model.Asset("file.txt") @tf.function(input_signature=) def func(): return tf.io.read_file(filename) trackable_obj = tf.train.Checkpoint() trackable_obj.func = func trackable_obj.filename = filename tf.saved_model.save(trackable_obj, "/tmp/saved_model") # The created SavedMo