数据接口
get_asc_insert_func
获取数据预处理函数。
def get_asc_insert_func(tgt_key_specs=None, args_index_list=None, table_names=None, **kwargs)
| 参数名 | 类型 | 说明 |
|---|---|---|
| tgt_key_specs | 特征对象或特征对象列表或者特征对象元组,默认值为None。 | |
| args_index_list | list[int] | 参数索引列表,默认值为None。取值范围:[1, 2^31-1] |
| table_names | list[str] | 表名称列表,默认值为None。取值范围:[1, 2^31-1] |
Note
接口参数可选择以下其中一种方式传入。
- 仅传入“tgt_key_specs”。
- 传入“args_index_list”和“table_names”。
| 参数名 | 类型 | 可选/必选 | 说明 |
|---|---|---|---|
| is_training | bool | 可选 | 是否为训练模式,默认值为True。 取值范围: |
| dump_graph | bool | 可选 | 是否保存模型图,默认值为False。 取值范围: |
Note
- **kwargs参数中的“is_training”和“dump_graph”作为内部使用参数,不建议用户通过kwargs传递这两个参数。
- 如果通过kwargs传递其他未说明参数,则Rec SDK TensorFlow内部不会使用到该参数。
- 成功:数据预处理函数。
- 失败:抛出异常。
import tensorflow as tf
from mx_rec.core.asc.helper import get_asc_insert_func
dataset = tf.data.TFRecordDataset(data_path) # data_path为数据集路径
dataset = dataset.map(get_asc_insert_func(tgt_key_specs=feature_spec_list, is_training=True)) # feature_spec_list中元素为FeatureSpec对象
接口调用流程及示例,参见迁移与训练。
modify_graph_and_start_emb_cache
开启自动改图模式下的数据加载和预处理接口。
def modify_graph_and_start_emb_cache(full_graph = None, dump_graph = False)
| 参数名 | 类型 | 可选/必选 | 说明 |
|---|---|---|---|
| full_graph | tf.Graph | 可选 | 改图支持传入图实例,默认为None,None会被赋值为tf.compat.v1.get_default_graph()。 |
| dump_graph | bool | 可选 | 是否保存模型图,默认值为False。 取值范围: |
- 成功:返回None。
- 失败:抛出异常。
from mx_rec.graph.modifier import modify_graph_and_start_emb_cache
MODIFY_GRAPH_FLAG = True
if MODIFY_GRAPH_FLAG:
modify_graph_and_start_emb_cache(dump_graph=True)
接口调用流程及示例,参见迁移与训练。
start_asc_pipeline
非自动改图模式下,初始化并启动数据预处理流水。
def start_asc_pipeline()
- 成功:返回None。
- 失败:抛出异常。
from mx_rec.core.asc.manager import start_asc_pipeline
MODIFY_GRAPH_FLAG = False
if not MODIFY_GRAPH_FLAG:
start_asc_pipeline()
接口调用流程及示例,参见迁移与训练。