Skip to content

Commit

Permalink
Open [xdoctest][task 315] reformat example code with google style in…
Browse files Browse the repository at this point in the history
… python/paddle/sparse/nn/layer/conv.py (#57133)
  • Loading branch information
yoyoIcy authored Sep 11, 2023
1 parent 0aad84e commit 0ec84a5
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions python/paddle/sparse/nn/layer/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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__(
Expand Down Expand Up @@ -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__(
Expand Down Expand Up @@ -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__(
Expand Down

0 comments on commit 0ec84a5

Please sign in to comment.