提交 ccb553fe 编写于 作者: W wangkuiyi 提交者: GitHub

Merge pull request #1253 from wangkuiyi/python_learning_and_refactor

Rename Python function DataBase into create_data_config_proto
...@@ -893,11 +893,11 @@ class MaxOut(Cfg): ...@@ -893,11 +893,11 @@ class MaxOut(Cfg):
self.add_keys(locals()) self.add_keys(locals())
def DataBase(async_load_data=False, def create_data_config_proto(async_load_data=False,
constant_slots=None, constant_slots=None,
data_ratio=1, data_ratio=1,
is_main_data=True, is_main_data=True,
usage_ratio=None): usage_ratio=None):
# default: all sub dataproviders are treat as "main data". # default: all sub dataproviders are treat as "main data".
# see proto/DataConfig.proto for is_main_data # see proto/DataConfig.proto for is_main_data
data_config = DataConfig() data_config = DataConfig()
...@@ -923,7 +923,7 @@ def SimpleData(files=None, ...@@ -923,7 +923,7 @@ def SimpleData(files=None,
context_len=None, context_len=None,
buffer_capacity=None, buffer_capacity=None,
**xargs): **xargs):
data_config = DataBase(**xargs) data_config = create_data_config_proto(**xargs)
data_config.type = 'simple' data_config.type = 'simple'
data_config.files = files data_config.files = files
data_config.feat_dim = feat_dim data_config.feat_dim = feat_dim
...@@ -945,7 +945,7 @@ def PyData(files=None, ...@@ -945,7 +945,7 @@ def PyData(files=None,
constant_slots=None, constant_slots=None,
load_thread_num=None, load_thread_num=None,
**xargs): **xargs):
data_config = DataBase(**xargs) data_config = create_data_config_proto(**xargs)
data_config.type = 'py' data_config.type = 'py'
if load_data_module in g_py_module_name_list: if load_data_module in g_py_module_name_list:
...@@ -996,7 +996,7 @@ def ProtoData(files=None, ...@@ -996,7 +996,7 @@ def ProtoData(files=None,
constant_slots=None, constant_slots=None,
load_thread_num=None, load_thread_num=None,
**xargs): **xargs):
data_config = DataBase(**xargs) data_config = create_data_config_proto(**xargs)
if type is None: if type is None:
data_config.type = 'proto' data_config.type = 'proto'
else: else:
...@@ -1035,7 +1035,7 @@ def Data(type, ...@@ -1035,7 +1035,7 @@ def Data(type,
buffer_capacity=None, buffer_capacity=None,
**xargs): **xargs):
data_config = DataBase(**xargs) data_config = create_data_config_proto(**xargs)
data_config.type = type data_config.type = type
data_config.files = files data_config.files = files
data_config.feat_dim = feat_dim data_config.feat_dim = feat_dim
......
...@@ -58,8 +58,8 @@ def define_py_data_source(file_list, ...@@ -58,8 +58,8 @@ def define_py_data_source(file_list,
:param obj: python object name. May be a function name if using :param obj: python object name. May be a function name if using
PyDataProviderWrapper. PyDataProviderWrapper.
:type obj: basestring :type obj: basestring
:param args: The best practice is using dict to pass arguments into :param args: The best practice is using dict to pass arguments into
DataProvider, and use :code:`@init_hook_wrapper` to DataProvider, and use :code:`@init_hook_wrapper` to
receive arguments. receive arguments.
:type args: string or picklable object :type args: string or picklable object
:param async: Load Data asynchronously or not. :param async: Load Data asynchronously or not.
...@@ -98,7 +98,7 @@ def define_py_data_sources(train_list, ...@@ -98,7 +98,7 @@ def define_py_data_sources(train_list,
The annotation is almost the same as define_py_data_sources2, except that The annotation is almost the same as define_py_data_sources2, except that
it can specific train_async and data_cls. it can specific train_async and data_cls.
:param data_cls: :param data_cls:
:param train_list: Train list name. :param train_list: Train list name.
:type train_list: basestring :type train_list: basestring
:param test_list: Test list name. :param test_list: Test list name.
...@@ -111,8 +111,8 @@ def define_py_data_sources(train_list, ...@@ -111,8 +111,8 @@ def define_py_data_sources(train_list,
a tuple or list to this argument. a tuple or list to this argument.
:type obj: basestring or tuple or list :type obj: basestring or tuple or list
:param args: The best practice is using dict() to pass arguments into :param args: The best practice is using dict() to pass arguments into
DataProvider, and use :code:`@init_hook_wrapper` to receive DataProvider, and use :code:`@init_hook_wrapper` to receive
arguments. If train and test is different, then pass a tuple arguments. If train and test is different, then pass a tuple
or list to this argument. or list to this argument.
:type args: string or picklable object or list or tuple. :type args: string or picklable object or list or tuple.
:param train_async: Is training data load asynchronously or not. :param train_async: Is training data load asynchronously or not.
...@@ -163,12 +163,12 @@ def define_py_data_sources2(train_list, test_list, module, obj, args=None): ...@@ -163,12 +163,12 @@ def define_py_data_sources2(train_list, test_list, module, obj, args=None):
.. code-block:: python .. code-block:: python
define_py_data_sources2(train_list="train.list", define_py_data_sources2(train_list="train.list",
test_list="test.list", test_list="test.list",
module="data_provider" module="data_provider"
# if train/test use different configurations, # if train/test use different configurations,
# obj=["process_train", "process_test"] # obj=["process_train", "process_test"]
obj="process", obj="process",
args={"dictionary": dict_name}) args={"dictionary": dict_name})
The related data provider can refer to :ref:`api_pydataprovider2_sequential_model` . The related data provider can refer to :ref:`api_pydataprovider2_sequential_model` .
...@@ -185,8 +185,8 @@ def define_py_data_sources2(train_list, test_list, module, obj, args=None): ...@@ -185,8 +185,8 @@ def define_py_data_sources2(train_list, test_list, module, obj, args=None):
a tuple or list to this argument. a tuple or list to this argument.
:type obj: basestring or tuple or list :type obj: basestring or tuple or list
:param args: The best practice is using dict() to pass arguments into :param args: The best practice is using dict() to pass arguments into
DataProvider, and use :code:`@init_hook_wrapper` to receive DataProvider, and use :code:`@init_hook_wrapper` to receive
arguments. If train and test is different, then pass a tuple arguments. If train and test is different, then pass a tuple
or list to this argument. or list to this argument.
:type args: string or picklable object or list or tuple. :type args: string or picklable object or list or tuple.
:return: None :return: None
...@@ -195,7 +195,7 @@ def define_py_data_sources2(train_list, test_list, module, obj, args=None): ...@@ -195,7 +195,7 @@ def define_py_data_sources2(train_list, test_list, module, obj, args=None):
def py_data2(files, load_data_module, load_data_object, load_data_args, def py_data2(files, load_data_module, load_data_object, load_data_args,
**kwargs): **kwargs):
data = DataBase() data = create_data_config_proto()
data.type = 'py2' data.type = 'py2'
data.files = files data.files = files
data.load_data_module = load_data_module data.load_data_module = load_data_module
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册