easy_rec.python.model¶
easy_rec.python.model.easy_rec_model¶
- class easy_rec.python.model.easy_rec_model.EasyRecModel(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
object
- property embedding_regularization¶
- property kd¶
- property l2_regularization¶
- restore(ckpt_path, include_global_step=False, ckpt_var_map_path='', force_restore_shape_compatible=False)[source]¶
Restore variables from ckpt_path.
- steps:
list the variables in graph that need to be restored
inspect checkpoint and find the variables that could restore from checkpoint substitute scope names in case necessary
call tf.train.init_from_checkpoint to restore the variables
- Parameters
ckpt_path – checkpoint path to restore from
include_global_step – whether to restore global_step variable
ckpt_var_map_path – variable map from graph variables to variables in a checkpoint each line consists of: variable name in graph variable name in ckpt
force_restore_shape_compatible – if variable shape is incompatible, clip or pad variables in checkpoint, and then restore
- Returns
IncompatibleShapeRestoreHook if force_shape_compatible else None
- classmethod create_class(name)¶
easy_rec.python.model.rank_model¶
- class easy_rec.python.model.rank_model.RankModel(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.easy_rec_model.EasyRecModel
- classmethod create_class(name)¶
easy_rec.python.model.fm¶
- class easy_rec.python.model.fm.FM(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.wide_and_deep¶
- class easy_rec.python.model.wide_and_deep.WideAndDeep(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.deepfm¶
- class easy_rec.python.model.deepfm.DeepFM(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.multi_tower¶
- class easy_rec.python.model.multi_tower.MultiTower(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.dcn¶
- class easy_rec.python.model.dcn.DCN(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.autoint¶
- class easy_rec.python.model.autoint.AutoInt(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.dbmtl¶
- class easy_rec.python.model.dbmtl.DBMTL(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.multi_task_model.MultiTaskModel
- classmethod create_class(name)¶
easy_rec.python.model.multi_tower_bst¶
- class easy_rec.python.model.multi_tower_bst.MultiTowerBST(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.multi_tower_din¶
- class easy_rec.python.model.multi_tower_din.MultiTowerDIN(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.dssm¶
- class easy_rec.python.model.dssm.DSSM(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.easy_rec_model.EasyRecModel
- classmethod create_class(name)¶
easy_rec.python.model.mind¶
- class easy_rec.python.model.mind.MIND(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.easy_rec_model.EasyRecModel
- classmethod create_class(name)¶
easy_rec.python.model.multi_task_model¶
- class easy_rec.python.model.multi_task_model.MultiTaskModel(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.rank_model.RankModel
- classmethod create_class(name)¶
easy_rec.python.model.mmoe¶
- class easy_rec.python.model.mmoe.MMoE(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.multi_task_model.MultiTaskModel
- classmethod create_class(name)¶
easy_rec.python.model.esmm¶
- class easy_rec.python.model.esmm.ESMM(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.multi_task_model.MultiTaskModel
- build_loss_graph()[source]¶
Build loss graph.
- Returns
Weighted loss of ctr and cvr.
- Return type
self._loss_dict
- build_metric_graph(eval_config)[source]¶
Build metric graph.
- Parameters
eval_config – Evaluation configuration.
- Returns
Calculate AUC of ctr, cvr and ctrvr.
- Return type
metric_dict
- build_predict_graph()[source]¶
Forward function.
- Returns
Prediction result of two tasks.
- Return type
self._prediction_dict
- classmethod create_class(name)¶
easy_rec.python.model.easy_rec_estimator¶
- class easy_rec.python.model.simple_multi_task.SimpleMultiTask(model_config, feature_configs, features, labels=None, is_training=False)[source]¶
Bases:
easy_rec.python.model.multi_task_model.MultiTaskModel
- classmethod create_class(name)¶
easy_rec.python.model.easy_rec_estimator¶
- class easy_rec.python.model.easy_rec_estimator.EasyRecEstimator(pipeline_config, model_cls, run_config, params)[source]¶
Bases:
tensorflow_estimator.python.estimator.estimator.Estimator
- __init__(pipeline_config, model_cls, run_config, params)[source]¶
Constructs an Estimator instance.
- Parameters
model_fn – Model function. Follows the signature: * features – This is the first item returned from the input_fn passed to train, evaluate, and predict. This should be a single tf.Tensor or dict of same. * labels – This is the second item returned from the input_fn passed to train, evaluate, and predict. This should be a single tf.Tensor or dict of same (for multi-head models). If mode is tf.estimator.ModeKeys.PREDICT, labels=None will be passed. If the model_fn’s signature does not accept mode, the model_fn must still be able to handle labels=None. * mode – Optional. Specifies if this is training, evaluation or prediction. See tf.estimator.ModeKeys. params – Optional dict of hyperparameters. Will receive what is passed to Estimator in params parameter. This allows to configure Estimators from hyper parameter tuning. * config – Optional estimator.RunConfig object. Will receive what is passed to Estimator as its config parameter, or a default value. Allows setting up things in your model_fn based on configuration such as num_ps_replicas, or model_dir. * Returns – tf.estimator.EstimatorSpec
model_dir – Directory to save model parameters, graph and etc. This can also be used to load checkpoints from the directory into an estimator to continue training a previously saved model. If PathLike object, the path will be resolved. If None, the model_dir in config will be used if set. If both are set, they must be same. If both are None, a temporary directory will be used.
config – estimator.RunConfig configuration object.
params – dict of hyper parameters that will be passed into model_fn. Keys are names of parameters, values are basic python types.
warm_start_from – Optional string filepath to a checkpoint or SavedModel to warm-start from, or a tf.estimator.WarmStartSettings object to fully configure warm-starting. If None, only TRAINABLE variables are warm-started. If the string filepath is provided instead of a tf.estimator.WarmStartSettings, then all variables are warm-started, and it is assumed that vocabularies and tf.Tensor names are unchanged.
- Raises
ValueError – parameters of model_fn don’t match params.
ValueError – if this is called via a subclass and if that class overrides a member of Estimator.
- property feature_configs¶
- property model_config¶
- property eval_config¶
- property train_config¶
- property export_config¶