-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[xdoctest][task 330] reformat example code with google style in python/paddle/base/data_feed_desc.py #57137
[xdoctest][task 330] reformat example code with google style in python/paddle/base/data_feed_desc.py #57137
Changes from 1 commit
53c219c
afc17fb
4157dff
1a7b69d
34c2043
90beb05
d856970
1997cb4
f760ac7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,26 +33,26 @@ class DataFeedDesc: | |
|
||
.. code-block:: python | ||
|
||
import paddle.base as base | ||
f = open("data.proto", "w") | ||
print >> f, 'name: "MultiSlotDataFeed"' | ||
print >> f, 'batch_size: 2' | ||
print >> f, 'multi_slot_desc {' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "words"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "label"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, '}' | ||
f.close() | ||
data_feed = base.DataFeedDesc('data.proto') | ||
>>> import paddle.base as base | ||
>>> f = open("data.proto", "w") | ||
>>> print >> f, 'name: "MultiSlotDataFeed"' | ||
>>> print >> f, 'batch_size: 2' | ||
>>> print >> f, 'multi_slot_desc {' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "words"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "label"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, '}' | ||
>>> f.close() | ||
>>> data_feed = base.DataFeedDesc('data.proto') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这段代码换成 python3 写法吧
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这段应该不能算是示例,把 |
||
|
||
However, users usually shouldn't care about the message format; instead, | ||
they are encouraged to use :code:`Data Generator` as a tool to generate a | ||
|
@@ -64,17 +64,17 @@ class DataFeedDesc: | |
|
||
.. code-block:: python | ||
|
||
import paddle.base as base | ||
data_feed = base.DataFeedDesc('data.proto') | ||
data_feed.set_batch_size(128) | ||
data_feed.set_dense_slots('wd') # The slot named 'wd' will be dense | ||
data_feed.set_use_slots('wd') # The slot named 'wd' will be used | ||
>>> import paddle.base as base | ||
>>> data_feed = base.DataFeedDesc('data.proto') | ||
>>> data_feed.set_batch_size(128) | ||
>>> data_feed.set_dense_slots('wd') # The slot named 'wd' will be dense | ||
>>> data_feed.set_use_slots('wd') # The slot named 'wd' will be used | ||
|
||
Finally, the content can be dumped out for debugging purpose: | ||
|
||
.. code-block:: python | ||
|
||
print(data_feed.desc()) | ||
>>> print(data_feed.desc()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 ~ |
||
|
||
Args: | ||
proto_file(string): Disk file containing a data feed description. | ||
|
@@ -99,27 +99,27 @@ def set_batch_size(self, batch_size): | |
Example: | ||
yoyoIcy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.. code-block:: python | ||
|
||
import paddle.base as base | ||
f = open("data.proto", "w") | ||
print >> f, 'name: "MultiSlotDataFeed"' | ||
print >> f, 'batch_size: 2' | ||
print >> f, 'multi_slot_desc {' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "words"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "label"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, '}' | ||
f.close() | ||
data_feed = base.DataFeedDesc('data.proto') | ||
data_feed.set_batch_size(128) | ||
>>> import paddle.base as base | ||
>>> f = open("data.proto", "w") | ||
>>> print >> f, 'name: "MultiSlotDataFeed"' | ||
>>> print >> f, 'batch_size: 2' | ||
>>> print >> f, 'multi_slot_desc {' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "words"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "label"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, '}' | ||
>>> f.close() | ||
>>> data_feed = base.DataFeedDesc('data.proto') | ||
>>> data_feed.set_batch_size(128) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果这里作为示例出现的话,需要把里面的这些 print 修改一下,改为正常 python 的写文件语句~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 统一一下吧,改成可以跑的 我一小时前 review 一半干别的去了,结果回来后你已经 review 了 😂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. github 时好时坏 ... ... 趁着好用 review 一下 ~ |
||
|
||
Args: | ||
batch_size (int): The number of batch size. | ||
|
@@ -140,27 +140,27 @@ def set_dense_slots(self, dense_slots_name): | |
Example: | ||
.. code-block:: python | ||
|
||
import paddle.base as base | ||
f = open("data.proto", "w") | ||
print >> f, 'name: "MultiSlotDataFeed"' | ||
print >> f, 'batch_size: 2' | ||
print >> f, 'multi_slot_desc {' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "words"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "label"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, '}' | ||
f.close() | ||
data_feed = base.DataFeedDesc('data.proto') | ||
data_feed.set_dense_slots(['words']) | ||
>>> import paddle.base as base | ||
>>> f = open("data.proto", "w") | ||
>>> print >> f, 'name: "MultiSlotDataFeed"' | ||
>>> print >> f, 'batch_size: 2' | ||
>>> print >> f, 'multi_slot_desc {' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "words"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "label"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, '}' | ||
>>> f.close() | ||
>>> data_feed = base.DataFeedDesc('data.proto') | ||
>>> data_feed.set_dense_slots(['words']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
||
|
||
Args: | ||
dense_slots_name (list(str)): a list of slot names which will be set dense. | ||
|
@@ -187,27 +187,27 @@ def set_use_slots(self, use_slots_name): | |
Example: | ||
.. code-block:: python | ||
|
||
import paddle.base as base | ||
f = open("data.proto", "w") | ||
print >> f, 'name: "MultiSlotDataFeed"' | ||
print >> f, 'batch_size: 2' | ||
print >> f, 'multi_slot_desc {' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "words"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "label"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, '}' | ||
f.close() | ||
data_feed = base.DataFeedDesc('data.proto') | ||
data_feed.set_use_slots(['words']) | ||
>>> import paddle.base as base | ||
>>> f = open("data.proto", "w") | ||
>>> print >> f, 'name: "MultiSlotDataFeed"' | ||
>>> print >> f, 'batch_size: 2' | ||
>>> print >> f, 'multi_slot_desc {' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "words"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "label"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, '}' | ||
>>> f.close() | ||
>>> data_feed = base.DataFeedDesc('data.proto') | ||
>>> data_feed.set_use_slots(['words']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
||
|
||
Args: | ||
use_slots_name: a list of slot names which will be used in training | ||
|
@@ -231,27 +231,27 @@ def desc(self): | |
Example: | ||
.. code-block:: python | ||
|
||
import paddle.base as base | ||
f = open("data.proto", "w") | ||
print >> f, 'name: "MultiSlotDataFeed"' | ||
print >> f, 'batch_size: 2' | ||
print >> f, 'multi_slot_desc {' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "words"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, ' slots {' | ||
print >> f, ' name: "label"' | ||
print >> f, ' type: "uint64"' | ||
print >> f, ' is_dense: false' | ||
print >> f, ' is_used: true' | ||
print >> f, ' }' | ||
print >> f, '}' | ||
f.close() | ||
data_feed = base.DataFeedDesc('data.proto') | ||
print(data_feed.desc()) | ||
>>> import paddle.base as base | ||
>>> f = open("data.proto", "w") | ||
>>> print >> f, 'name: "MultiSlotDataFeed"' | ||
>>> print >> f, 'batch_size: 2' | ||
>>> print >> f, 'multi_slot_desc {' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "words"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, ' slots {' | ||
>>> print >> f, ' name: "label"' | ||
>>> print >> f, ' type: "uint64"' | ||
>>> print >> f, ' is_dense: false' | ||
>>> print >> f, ' is_used: true' | ||
>>> print >> f, ' }' | ||
>>> print >> f, '}' | ||
>>> f.close() | ||
>>> data_feed = base.DataFeedDesc('data.proto') | ||
>>> print(data_feed.desc()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
||
|
||
Returns: | ||
A string message | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放在
Examples:
之下吧,记得整体加缩进