未验证 提交 ff7e6ec5 编写于 作者: M megemini 提交者: GitHub

[Fix]fix cleandoc with a first blank line (#55052)

* [Fix]fix cleandoc with a first blank line

* [Fix]fix metrics.py code-block

* [Fix]fix metrics.py code-block indent
上级 ef19521c
......@@ -82,7 +82,8 @@ class Metric(metaclass=abc.ABCMeta):
prediction of each sample like follows, while the correct prediction
matrix shape is [N, 5].
.. code-block:: text
.. code-block:: python
:name: code-compute-example
def compute(pred, label):
# sort prediction and slice the top-5 scores
......@@ -96,7 +97,8 @@ class Metric(metaclass=abc.ABCMeta):
shape as [N, 5] instead of 2 tensors with shapes as [N, 10] and [N, 1].
:code:`update` can be define as follows:
.. code-block:: text
.. code-block:: python
:name: code-update-example
def update(self, correct):
accs = []
......@@ -195,9 +197,9 @@ class Accuracy(Metric):
name (str, optional): String name of the metric instance. Default
is `acc`.
Example by standalone:
Examples:
.. code-block:: python
:name: code-standalone-example
import numpy as np
import paddle
......@@ -215,10 +217,8 @@ class Accuracy(Metric):
res = m.accumulate()
print(res) # 0.75
Example with Model API:
.. code-block:: python
:name: code-model-api-example
import paddle
from paddle.static import InputSpec
......@@ -349,9 +349,9 @@ class Precision(Metric):
name (str, optional): String name of the metric instance.
Default is `precision`.
Example by standalone:
Examples:
.. code-block:: python
:name: code-standalone-example
import numpy as np
import paddle
......@@ -364,10 +364,8 @@ class Precision(Metric):
res = m.accumulate()
print(res) # 1.0
Example with Model API:
.. code-block:: python
:name: code-model-api-example
import numpy as np
......@@ -482,9 +480,9 @@ class Recall(Metric):
name (str, optional): String name of the metric instance.
Default is `recall`.
Example by standalone:
Examples:
.. code-block:: python
:name: code-standalone-example
import numpy as np
import paddle
......@@ -497,10 +495,8 @@ class Recall(Metric):
res = m.accumulate()
print(res) # 2.0 / 3.0
Example with Model API:
.. code-block:: python
:name: code-model-api-example
import numpy as np
......@@ -624,8 +620,9 @@ class Auc(Metric):
"NOTE: only implement the ROC curve type via Python now."
Example by standalone:
Examples:
.. code-block:: python
:name: code-standalone-example
import numpy as np
import paddle
......@@ -642,10 +639,8 @@ class Auc(Metric):
m.update(preds=preds, labels=labels)
res = m.accumulate()
Example with Model API:
.. code-block:: python
:name: code-model-api-example
import numpy as np
import paddle
......
......@@ -151,7 +151,7 @@ def extract_code_blocks_from_docstr(docstr):
# nonlocal code_blocks, cb_cur, cb_cur_name, cb_cur_seq_id, cb_required
code_blocks.append(
{
'codes': inspect.cleandoc("\n".join(cb_info['cb_cur'])),
'codes': inspect.cleandoc("\n" + "\n".join(cb_info['cb_cur'])),
'name': cb_info['cb_cur_name'],
'id': cb_info['cb_cur_seq_id'],
'required': cb_info['cb_required'],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册