npu_bridge.estimator.npu.keras_to_npu
model_to_npu_estimator
Prototype
def model_to_npu_estimator(keras_model=None,
keras_model_path=None,
custom_objects=None,
model_dir=None,
checkpoint_format='saver',
config=None,
job_start_file='')
Description
Converts the model built by using Keras to an NPUEstimator object.
Restrictions
Currently, only the function model and sequence model (Keras graph construction mode) can be converted into an NPUEstimator object using the model_to_npu_estimator API.
Parameters
Parameter |
Description |
---|---|
keras_model |
Built Keras model object. This parameter and keras_model_path cannot be input at the same time. |
keras_model_path |
Path for storing the built Keras model on the drive. You can use the save() method of the Keras model to generate a Keras model in HDF5 format. This parameter and keras_model cannot be input at the same time. |
custom_objects |
Dictionary of user-defined objects. If a user-defined layer or function is used during Keras construction, custom_objects must be used during model loading. |
model_dir |
Model directory, which is used to save or restore model files. If this parameter is not set, the value of model_dir in the config file is used. If both parameters are set, the values of the two parameters must be the same. If both parameters are set to None, the temporary directory /tmp is used. |
checkpoint_format |
Sets the format of the checkpoint file saved by NPUEstimator during training. Values:
|
config |
NPURunConfig class object, which is used to configure NPUEstimator running parameters. For details about the constructor of the NPURunConfig class, see NPURunConfig Constructor. |
job_start_file |
Path of the configuration file used to start the training process in the CSA scenario. This parameter does not need to be set in the cloud scenario. |
Returns
An NPUEstimator object is returned based on the input Keras model.