未验证 提交 34eecb0e 编写于 作者: 张春乔 提交者: GitHub

[xdoctest] reformat example code with google style in No.307 (#56595)

* weight_norm_hook

* Update weight_norm_hook.py

* Update weight_norm_hook.py

* Update python/paddle/nn/utils/weight_norm_hook.py

* Update python/paddle/nn/utils/weight_norm_hook.py

* Update python/paddle/nn/utils/weight_norm_hook.py
Co-authored-by: NNyakku Shigure <sigure.qaq@gmail.com>

* xdoc

* Apply suggestions from code review

* Apply suggestions from code review

---------
Co-authored-by: NNyakku Shigure <sigure.qaq@gmail.com>
上级 220f13bd
......@@ -22,22 +22,26 @@ class EntryAttr:
Examples:
.. code-block:: python
import paddle
>>> import paddle
>>> paddle.enable_static()
sparse_feature_dim = 1024
embedding_size = 64
>>> sparse_feature_dim = 1024
>>> embedding_size = 64
entry = paddle.distributed.ProbabilityEntry(0.1)
>>> entry = paddle.distributed.ProbabilityEntry(0.1)
input = paddle.static.data(name='ins', shape=[1], dtype='int64')
>>> input = paddle.static.data(name='ins', shape=[1], dtype='int64')
emb = paddle.static.nn.sparse_embedding((
input=input,
size=[sparse_feature_dim, embedding_size],
is_test=False,
entry=entry,
param_attr=paddle.ParamAttr(name="SparseFeatFactors",
initializer=paddle.nn.initializer.Uniform()))
>>> emb = paddle.static.nn.sparse_embedding(
... input=input,
... size=[sparse_feature_dim, embedding_size],
... is_test=False,
... entry=entry,
... param_attr=paddle.ParamAttr(
... name="SparseFeatFactors",
... initializer=paddle.nn.initializer.Uniform()
... )
... )
"""
......@@ -59,22 +63,26 @@ class ProbabilityEntry(EntryAttr):
Examples:
.. code-block:: python
import paddle
>>> import paddle
>>> paddle.enable_static()
sparse_feature_dim = 1024
embedding_size = 64
>>> sparse_feature_dim = 1024
>>> embedding_size = 64
entry = paddle.distributed.ProbabilityEntry(0.1)
>>> entry = paddle.distributed.ProbabilityEntry(0.1)
input = paddle.static.data(name='ins', shape=[1], dtype='int64')
>>> input = paddle.static.data(name='ins', shape=[1], dtype='int64')
emb = paddle.static.nn.sparse_embedding((
input=input,
size=[sparse_feature_dim, embedding_size],
is_test=False,
entry=entry,
param_attr=paddle.ParamAttr(name="SparseFeatFactors",
initializer=paddle.nn.initializer.Uniform()))
>>> emb = paddle.static.nn.sparse_embedding(
... input=input,
... size=[sparse_feature_dim, embedding_size],
... is_test=False,
... entry=entry,
... param_attr=paddle.ParamAttr(
... name="SparseFeatFactors",
... initializer=paddle.nn.initializer.Uniform()
... )
... )
"""
......@@ -100,22 +108,26 @@ class CountFilterEntry(EntryAttr):
Examples:
.. code-block:: python
import paddle
>>> import paddle
>>> paddle.enable_static()
sparse_feature_dim = 1024
embedding_size = 64
>>> sparse_feature_dim = 1024
>>> embedding_size = 64
entry = paddle.distributed.CountFilterEntry(10)
>>> entry = paddle.distributed.CountFilterEntry(10)
input = paddle.static.data(name='ins', shape=[1], dtype='int64')
>>> input = paddle.static.data(name='ins', shape=[1], dtype='int64')
emb = paddle.static.nn.sparse_embedding((
input=input,
size=[sparse_feature_dim, embedding_size],
is_test=False,
entry=entry,
param_attr=paddle.ParamAttr(name="SparseFeatFactors",
initializer=paddle.nn.initializer.Uniform()))
>>> emb = paddle.static.nn.sparse_embedding(
... input=input,
... size=[sparse_feature_dim, embedding_size],
... is_test=False,
... entry=entry,
... param_attr=paddle.ParamAttr(
... name="SparseFeatFactors",
... initializer=paddle.nn.initializer.Uniform()
... )
... )
"""
......@@ -144,25 +156,28 @@ class ShowClickEntry(EntryAttr):
Examples:
.. code-block:: python
import paddle
paddle.enable_static()
>>> import paddle
>>> paddle.enable_static()
sparse_feature_dim = 1024
embedding_size = 64
>>> sparse_feature_dim = 1024
>>> embedding_size = 64
shows = paddle.static.data(name='show', shape=[1], dtype='int64')
clicks = paddle.static.data(name='click', shape=[1], dtype='int64')
input = paddle.static.data(name='ins', shape=[1], dtype='int64')
>>> shows = paddle.static.data(name='show', shape=[1], dtype='int64')
>>> clicks = paddle.static.data(name='click', shape=[1], dtype='int64')
>>> input = paddle.static.data(name='ins', shape=[1], dtype='int64')
entry = paddle.distributed.ShowClickEntry("show", "click")
>>> entry = paddle.distributed.ShowClickEntry("show", "click")
emb = paddle.static.nn.sparse_embedding(
input=input,
size=[sparse_feature_dim, embedding_size],
is_test=False,
entry=entry,
param_attr=paddle.ParamAttr(name="SparseFeatFactors",
initializer=paddle.nn.initializer.Uniform()))
>>> emb = paddle.static.nn.sparse_embedding(
... input=input,
... size=[sparse_feature_dim, embedding_size],
... is_test=False,
... entry=entry,
... param_attr=paddle.ParamAttr(
... name="SparseFeatFactors",
... initializer=paddle.nn.initializer.Uniform()
... )
... )
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册