未验证 提交 3c2276e6 编写于 作者: Y yuchen202 提交者: GitHub

[xdoctest] reformat example code with google style in No.284-285 (#56784)

上级 5425ad7f
...@@ -49,10 +49,10 @@ def identity_loss(x, reduction="none"): ...@@ -49,10 +49,10 @@ def identity_loss(x, reduction="none"):
.. code-block:: python .. code-block:: python
import paddle >>> import paddle
paddle.enable_static() >>> paddle.enable_static()
loss = paddle.static.data(name="loss", shape=[-1, 1], dtype="float32") >>> loss = paddle.static.data(name="loss", shape=[-1, 1], dtype="float32")
out = paddle.incubate.identity_loss(loss, reduction=1) >>> out = paddle.incubate.identity_loss(loss, reduction=1)
""" """
if isinstance(reduction, str): if isinstance(reduction, str):
reduction = {"sum": 0, "mean": 1, "none": 2}.get(reduction.lower()) reduction = {"sum": 0, "mean": 1, "none": 2}.get(reduction.lower())
......
...@@ -70,17 +70,17 @@ def graph_khop_sampler( ...@@ -70,17 +70,17 @@ def graph_khop_sampler(
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle >>> import paddle
row = [3, 7, 0, 9, 1, 4, 2, 9, 3, 9, 1, 9, 7] >>> row = [3, 7, 0, 9, 1, 4, 2, 9, 3, 9, 1, 9, 7]
colptr = [0, 2, 4, 5, 6, 7, 9, 11, 11, 13, 13] >>> colptr = [0, 2, 4, 5, 6, 7, 9, 11, 11, 13, 13]
nodes = [0, 8, 1, 2] >>> nodes = [0, 8, 1, 2]
sample_sizes = [2, 2] >>> sample_sizes = [2, 2]
row = paddle.to_tensor(row, dtype="int64") >>> row = paddle.to_tensor(row, dtype="int64")
colptr = paddle.to_tensor(colptr, dtype="int64") >>> colptr = paddle.to_tensor(colptr, dtype="int64")
nodes = paddle.to_tensor(nodes, dtype="int64") >>> nodes = paddle.to_tensor(nodes, dtype="int64")
edge_src, edge_dst, sample_index, reindex_nodes = paddle.incubate.graph_khop_sampler(row, colptr, nodes, sample_sizes, False) >>> edge_src, edge_dst, sample_index, reindex_nodes = paddle.incubate.graph_khop_sampler(row, colptr, nodes, sample_sizes, False)
""" """
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册