|
|
|
@ -24,18 +24,18 @@ of 28 x 28 pixels.
|
|
|
|
|
|
|
|
|
|
|
|
A small part of the original data as an example is shown as below:
|
|
|
|
A small part of the original data as an example is shown as below:
|
|
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../doc_cn/ui/data_provider/mnist_train.txt
|
|
|
|
.. literalinclude:: src/mnist_train.txt
|
|
|
|
|
|
|
|
|
|
|
|
Each line of the data contains two parts, separated by :code:`;`. The first part is
|
|
|
|
Each line of the data contains two parts, separated by :code:`;`. The first part is
|
|
|
|
label of an image. The second part contains 28x28 pixel float values.
|
|
|
|
label of an image. The second part contains 28x28 pixel float values.
|
|
|
|
|
|
|
|
|
|
|
|
Just write path of the above data into train.list. It looks like this:
|
|
|
|
Just write path of the above data into train.list. It looks like this:
|
|
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../doc_cn/ui/data_provider/train.list
|
|
|
|
.. literalinclude:: src/train.list
|
|
|
|
|
|
|
|
|
|
|
|
The corresponding dataprovider is shown as below:
|
|
|
|
The corresponding dataprovider is shown as below:
|
|
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../doc_cn/ui/data_provider/mnist_provider.py
|
|
|
|
.. literalinclude:: src/mnist_provider.dict.py
|
|
|
|
|
|
|
|
|
|
|
|
The first line imports PyDataProvider2 package.
|
|
|
|
The first line imports PyDataProvider2 package.
|
|
|
|
The main function is the process function, that has two parameters.
|
|
|
|
The main function is the process function, that has two parameters.
|
|
|
|
@ -74,7 +74,7 @@ sample by using keywords :code:`yield`.
|
|
|
|
Only a few lines of codes need to be added into the training configuration file,
|
|
|
|
Only a few lines of codes need to be added into the training configuration file,
|
|
|
|
you can take this as an example.
|
|
|
|
you can take this as an example.
|
|
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../doc_cn/ui/data_provider/mnist_config.py
|
|
|
|
.. literalinclude:: src/mnist_config.py
|
|
|
|
|
|
|
|
|
|
|
|
Here we specify training data by :code:`train.list`, and no testing data is specified.
|
|
|
|
Here we specify training data by :code:`train.list`, and no testing data is specified.
|
|
|
|
The method which actually provide data is :code:`process`.
|
|
|
|
The method which actually provide data is :code:`process`.
|
|
|
|
@ -83,7 +83,7 @@ User also can use another style to provide data, which defines the
|
|
|
|
:code:`data_layer`'s name explicitly when `yield`. For example,
|
|
|
|
:code:`data_layer`'s name explicitly when `yield`. For example,
|
|
|
|
the :code:`dataprovider` is shown as below.
|
|
|
|
the :code:`dataprovider` is shown as below.
|
|
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../doc_cn/ui/data_provider/mnist_provider.dict.py
|
|
|
|
.. literalinclude:: src/mnist_provider.dict.py
|
|
|
|
:linenos:
|
|
|
|
:linenos:
|
|
|
|
|
|
|
|
|
|
|
|
If user did't give the :code:`data_layer`'s name, PaddlePaddle will use
|
|
|
|
If user did't give the :code:`data_layer`'s name, PaddlePaddle will use
|
|
|
|
@ -121,11 +121,11 @@ negative sentiment (marked by 0 and 1 respectively).
|
|
|
|
|
|
|
|
|
|
|
|
A small part of the original data as an example can be found in the path below:
|
|
|
|
A small part of the original data as an example can be found in the path below:
|
|
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../doc_cn/ui/data_provider/sentimental_train.txt
|
|
|
|
.. literalinclude:: src/sentimental_train.txt
|
|
|
|
|
|
|
|
|
|
|
|
The corresponding data provider can be found in the path below:
|
|
|
|
The corresponding data provider can be found in the path below:
|
|
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../doc_cn/ui/data_provider/sentimental_provider.py
|
|
|
|
.. literalinclude:: src/sentimental_provider.py
|
|
|
|
|
|
|
|
|
|
|
|
This data provider for sequential model is a little more complex than that
|
|
|
|
This data provider for sequential model is a little more complex than that
|
|
|
|
for MINST dataset.
|
|
|
|
for MINST dataset.
|
|
|
|
@ -143,7 +143,7 @@ initialized. The :code:`on_init` function has the following parameters:
|
|
|
|
To pass these parameters into DataProvider, the following lines should be added
|
|
|
|
To pass these parameters into DataProvider, the following lines should be added
|
|
|
|
into trainer configuration file.
|
|
|
|
into trainer configuration file.
|
|
|
|
|
|
|
|
|
|
|
|
.. literalinclude:: ../../../doc_cn/ui/data_provider/sentimental_config.py
|
|
|
|
.. literalinclude:: src/sentimental_config.py
|
|
|
|
|
|
|
|
|
|
|
|
The definition is basically same as MNIST example, except:
|
|
|
|
The definition is basically same as MNIST example, except:
|
|
|
|
* Load dictionary in this configuration
|
|
|
|
* Load dictionary in this configuration
|
|
|
|
|