easy_rec.python.main¶
- easy_rec.python.main.train_and_evaluate(pipeline_config_path, continue_train=False)[source]¶
Train and evaluate a EasyRec model defined in pipeline_config_path.
Build an EasyRecEstimator, and then train and evaluate the estimator.
- Parameters:
pipeline_config_path – a path to EasyRecConfig object, specifies
train_config – model_config, data_config and eval_config
continue_train – whether to restart train from an existing checkpoint
- Returns:
None, the model will be saved into pipeline_config.model_dir
- easy_rec.python.main.evaluate(pipeline_config, eval_checkpoint_path='', eval_data_path=None, eval_result_filename='eval_result.txt')[source]¶
Evaluate a EasyRec model defined in pipeline_config_path.
Evaluate the model defined in pipeline_config_path on the eval data, the metrics will be displayed on tensorboard and saved into eval_result.txt.
- Parameters:
pipeline_config – either EasyRecConfig path or its instance
eval_checkpoint_path – if specified, will use this model instead of model specified by model_dir in pipeline_config_path
eval_data_path – eval data path, default use eval data in pipeline_config could be a path or a list of paths
eval_result_filename – evaluation result metrics save path.
- Returns:
- the metrics are specified in
pipeline_config_path
global_step: the global step for which this evaluation was performed.
- Return type:
A dict of evaluation metrics
- Raises:
AssertionError, if –
pipeline_config_path does not exist
- easy_rec.python.main.predict(pipeline_config, checkpoint_path='', data_path=None)[source]¶
Predict a EasyRec model defined in pipeline_config_path.
Predict the model defined in pipeline_config_path on the eval data.
- Parameters:
pipeline_config – either EasyRecConfig path or its instance
checkpoint_path – if specified, will use this model instead of model specified by model_dir in pipeline_config_path
data_path – data path, default use eval data in pipeline_config could be a path or a list of paths
- Returns:
A list of dict of predict results
- Raises:
AssertionError, if –
pipeline_config_path does not exist
- easy_rec.python.main.export(export_dir, pipeline_config, checkpoint_path='', asset_files=None, verbose=False, **extra_params)[source]¶
Export model defined in pipeline_config_path.
- Parameters:
export_dir – base directory where the model should be exported
pipeline_config – proto.EasyRecConfig instance or file path specify proto.EasyRecConfig
checkpoint_path – if specified, will use this model instead of model in model_dir in pipeline_config_path
asset_files – extra files to add to assets, comma separated; if asset file variable in graph need to be renamed, specify by new_file_name:file_path
version – if version is defined, then will skip writing embedding to redis, assume that embedding is already write into redis
verbose – dumps debug information
extra_params – keys related to write embedding to redis/oss redis_url, redis_passwd, redis_threads, redis_batch_size, redis_timeout, redis_expire if export embedding to redis; redis_embedding_version: if specified, will kill export to redis – oss_path, oss_endpoint, oss_ak, oss_sk, oss_timeout, oss_expire, oss_write_kv, oss_embedding_version
- Returns:
the directory where model is exported
- Raises:
AssertionError, if –
pipeline_config_path does not exist