用法
save_spec(
dynamic_batch=True
)參數
-
dynamic_batch是否將所有返回的tf.TensorSpec的批量大小設置為None。 (請注意,使用tf.keras.Input([...], batch_size=X)定義函數或順序模型時,將始終保留批量大小)。默認為True。
返回
-
如果定義了模型輸入,則返回一個元組
(args, kwargs)。args和kwargs中的所有元素都是tf.TensorSpec。如果未定義模型輸入,則返回None。調用模型時會自動設置模型輸入model.fit,model.evaluate或model.predict。
以元組 (args, kwargs) 的形式返回調用輸入的 tf.TensorSpec。
該值在第一次調用模型後自動定義。之後,您可以在導出模型以供服務時使用它:
model = tf.keras.Model(...)
@tf.function
def serve(*args, **kwargs):
outputs = model(*args, **kwargs)
# Apply postprocessing steps, or add additional outputs.
...
return outputs
# arg_specs is `[tf.TensorSpec(...), ...]`. kwarg_specs, in this example, is
# an empty dict since functional models do not use keyword arguments.
arg_specs, kwarg_specs = model.save_spec()
model.save(path, signatures={
'serving_default':serve.get_concrete_function(*arg_specs, **kwarg_specs)
})
相關用法
- Python tf.keras.Model.save用法及代碼示例
- Python tf.keras.Model.compute_loss用法及代碼示例
- Python tf.keras.Model.reset_metrics用法及代碼示例
- Python tf.keras.Model.compile用法及代碼示例
- Python tf.keras.Model.compute_metrics用法及代碼示例
- Python tf.keras.Model用法及代碼示例
- Python tf.keras.applications.inception_resnet_v2.preprocess_input用法及代碼示例
- Python tf.keras.metrics.Mean.merge_state用法及代碼示例
- Python tf.keras.layers.InputLayer用法及代碼示例
- Python tf.keras.callbacks.ReduceLROnPlateau用法及代碼示例
- Python tf.keras.layers.serialize用法及代碼示例
- Python tf.keras.metrics.Hinge用法及代碼示例
- Python tf.keras.experimental.WideDeepModel.compute_loss用法及代碼示例
- Python tf.keras.metrics.SparseCategoricalAccuracy.merge_state用法及代碼示例
- Python tf.keras.metrics.RootMeanSquaredError用法及代碼示例
- Python tf.keras.applications.resnet50.preprocess_input用法及代碼示例
- Python tf.keras.metrics.SparseCategoricalCrossentropy.merge_state用法及代碼示例
- Python tf.keras.metrics.sparse_categorical_accuracy用法及代碼示例
- Python tf.keras.layers.Dropout用法及代碼示例
- Python tf.keras.activations.softplus用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.keras.Model.save_spec。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
