From 0ec84a54bf7f024e5e50bf77f9f63b4d53106a04 Mon Sep 17 00:00:00 2001 From: yoyoIcy <142126786+yoyoIcy@users.noreply.github.com> Date: Sun, 10 Sep 2023 22:55:37 -0500 Subject: [PATCH] Open [xdoctest][task 315] reformat example code with google style in python/paddle/sparse/nn/layer/conv.py (#57133) --- python/paddle/sparse/nn/layer/conv.py | 96 +++++++++++++-------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/python/paddle/sparse/nn/layer/conv.py b/python/paddle/sparse/nn/layer/conv.py index 4c77947c2ebaa2..d3295148fbc15e 100644 --- a/python/paddle/sparse/nn/layer/conv.py +++ b/python/paddle/sparse/nn/layer/conv.py @@ -326,18 +326,18 @@ class Conv3D(_Conv3D): .. code-block:: python - import paddle - - indices = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 2], [1, 3, 2, 3]] - values = [[1], [2], [3], [4]] - indices = paddle.to_tensor(indices, dtype='int32') - values = paddle.to_tensor(values, dtype='float32') - dense_shape = [1, 1, 3, 4, 1] - sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, dense_shape, stop_gradient=True) - conv = paddle.sparse.nn.Conv3D(1, 1, (1, 3, 3)) - y = conv(sparse_x) - print(y.shape) - # (1, 1, 1, 2, 1) + >>> import paddle + + >>> indices = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 2], [1, 3, 2, 3]] + >>> values = [[1], [2], [3], [4]] + >>> indices = paddle.to_tensor(indices, dtype='int32') + >>> values = paddle.to_tensor(values, dtype='float32') + >>> dense_shape = [1, 1, 3, 4, 1] + >>> sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, dense_shape, stop_gradient=True) + >>> conv = paddle.sparse.nn.Conv3D(1, 1, (1, 3, 3)) + >>> y = conv(sparse_x) + >>> print(y.shape) + [1, 1, 1, 2, 1] """ def __init__( @@ -461,18 +461,18 @@ class Conv2D(_Conv2D): .. code-block:: python - import paddle - - indices = [[0, 0, 0, 0], [0, 0, 1, 2], [1, 3, 2, 3]] - values = [[1], [2], [3], [4]] - indices = paddle.to_tensor(indices, dtype='int32') - values = paddle.to_tensor(values, dtype='float32') - dense_shape = [1, 3, 4, 1] - sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, dense_shape, stop_gradient=True) - conv = paddle.sparse.nn.Conv2D(1, 1, (3, 3)) - y = conv(sparse_x) - print(y.shape) - # (1, 1, 2, 1) + >>> import paddle + + >>> indices = [[0, 0, 0, 0], [0, 0, 1, 2], [1, 3, 2, 3]] + >>> values = [[1], [2], [3], [4]] + >>> indices = paddle.to_tensor(indices, dtype='int32') + >>> values = paddle.to_tensor(values, dtype='float32') + >>> dense_shape = [1, 3, 4, 1] + >>> sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, dense_shape, stop_gradient=True) + >>> conv = paddle.sparse.nn.Conv2D(1, 1, (3, 3)) + >>> y = conv(sparse_x) + >>> print(y.shape) + [1, 1, 2, 1] """ def __init__( @@ -600,18 +600,18 @@ class SubmConv3D(_Conv3D): .. code-block:: python - import paddle - - indices = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 2], [1, 3, 2, 3]] - values = [[1], [2], [3], [4]] - dense_shape = [1, 1, 3, 4, 1] - indices = paddle.to_tensor(indices, dtype='int32') - values = paddle.to_tensor(values, dtype='float32') - sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, dense_shape, stop_gradient=True) - subm_conv = paddle.sparse.nn.SubmConv3D(1, 1, (1, 3, 3)) - y = subm_conv(sparse_x) - print(y.shape) - # (1, 1, 3, 4, 1) + >>> import paddle + + >>> indices = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 2], [1, 3, 2, 3]] + >>> values = [[1], [2], [3], [4]] + >>> dense_shape = [1, 1, 3, 4, 1] + >>> indices = paddle.to_tensor(indices, dtype='int32') + >>> values = paddle.to_tensor(values, dtype='float32') + >>> sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, dense_shape, stop_gradient=True) + >>> subm_conv = paddle.sparse.nn.SubmConv3D(1, 1, (1, 3, 3)) + >>> y = subm_conv(sparse_x) + >>> print(y.shape) + [1, 1, 3, 4, 1] """ def __init__( @@ -740,18 +740,18 @@ class SubmConv2D(_Conv2D): .. code-block:: python - import paddle - - indices = [[0, 0, 0, 0], [0, 0, 1, 2], [1, 3, 2, 3]] - values = [[1], [2], [3], [4]] - dense_shape = [1, 3, 4, 1] - indices = paddle.to_tensor(indices, dtype='int32') - values = paddle.to_tensor(values, dtype='float32') - sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, dense_shape, stop_gradient=True) - subm_conv = paddle.sparse.nn.SubmConv2D(1, 1, (3, 3)) - y = subm_conv(sparse_x) - print(y.shape) - # (1, 3, 4, 1) + >>> import paddle + + >>> indices = [[0, 0, 0, 0], [0, 0, 1, 2], [1, 3, 2, 3]] + >>> values = [[1], [2], [3], [4]] + >>> dense_shape = [1, 3, 4, 1] + >>> indices = paddle.to_tensor(indices, dtype='int32') + >>> values = paddle.to_tensor(values, dtype='float32') + >>> sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, dense_shape, stop_gradient=True) + >>> subm_conv = paddle.sparse.nn.SubmConv2D(1, 1, (3, 3)) + >>> y = subm_conv(sparse_x) + >>> print(y.shape) + [1, 3, 4, 1] """ def __init__(