|
|
|
@ -438,20 +438,14 @@ def conv2d(x,
|
|
|
|
|
|
|
|
|
|
import paddle
|
|
|
|
|
import paddle.nn.functional as F
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
x = np.random.randn(2, 3, 8, 8).astype(np.float32)
|
|
|
|
|
w = np.random.randn(6, 3, 3, 3).astype(np.float32)
|
|
|
|
|
|
|
|
|
|
paddle.disable_static()
|
|
|
|
|
x_var = paddle.randn((2, 3, 8, 8), dtype='float32')
|
|
|
|
|
w_var = paddle.randn((6, 3, 3, 3), dtype='float32')
|
|
|
|
|
|
|
|
|
|
x_var = paddle.to_tensor(x)
|
|
|
|
|
w_var = paddle.to_tensor(w)
|
|
|
|
|
y_var = F.conv2d(x_var, w_var)
|
|
|
|
|
y_np = y_var.numpy()
|
|
|
|
|
|
|
|
|
|
print(y_np.shape)
|
|
|
|
|
|
|
|
|
|
# (2, 6, 6, 6)
|
|
|
|
|
"""
|
|
|
|
|
# entry checks
|
|
|
|
@ -946,20 +940,16 @@ def conv_transpose2d(x,
|
|
|
|
|
Examples:
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
import paddle
|
|
|
|
|
import paddle.nn.functional as F
|
|
|
|
|
|
|
|
|
|
x = np.random.randn(2, 3, 8, 8).astype(np.float32)
|
|
|
|
|
w = np.random.randn(3, 6, 3, 3).astype(np.float32)
|
|
|
|
|
x_var = paddle.randn((2, 3, 8, 8), dtype='float32')
|
|
|
|
|
w_var = paddle.randn((3, 6, 3, 3), dtype='float32')
|
|
|
|
|
|
|
|
|
|
paddle.disable_static()
|
|
|
|
|
x_var = paddle.to_tensor(x)
|
|
|
|
|
w_var = paddle.to_tensor(w)
|
|
|
|
|
y_var = F.conv_transpose2d(x_var, w_var)
|
|
|
|
|
y_np = y_var.numpy()
|
|
|
|
|
print(y_np.shape)
|
|
|
|
|
|
|
|
|
|
print(y_np.shape)
|
|
|
|
|
# (2, 6, 10, 10)
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
@ -1166,20 +1156,16 @@ def conv3d(x,
|
|
|
|
|
Examples:
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
import paddle
|
|
|
|
|
import paddle.nn.functional as F
|
|
|
|
|
|
|
|
|
|
x = np.random.randn(2, 3, 8, 8, 8).astype(np.float32)
|
|
|
|
|
w = np.random.randn(6, 3, 3, 3, 3).astype(np.float32)
|
|
|
|
|
x_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32')
|
|
|
|
|
w_var = paddle.randn((6, 3, 3, 3, 3), dtype='float32')
|
|
|
|
|
|
|
|
|
|
paddle.disable_static()
|
|
|
|
|
x_var = paddle.to_tensor(x)
|
|
|
|
|
w_var = paddle.to_tensor(w)
|
|
|
|
|
y_var = F.conv3d(x_var, w_var)
|
|
|
|
|
y_np = y_var.numpy()
|
|
|
|
|
print(y_np.shape)
|
|
|
|
|
|
|
|
|
|
print(y_np.shape)
|
|
|
|
|
# (2, 6, 6, 6, 6)
|
|
|
|
|
"""
|
|
|
|
|
# entry check
|
|
|
|
@ -1399,22 +1385,16 @@ def conv_transpose3d(x,
|
|
|
|
|
Examples:
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
import paddle
|
|
|
|
|
import paddle.nn.functional as F
|
|
|
|
|
|
|
|
|
|
x = np.random.randn(2, 3, 8, 8, 8).astype(np.float32)
|
|
|
|
|
w = np.random.randn(3, 6, 3, 3, 3).astype(np.float32)
|
|
|
|
|
x_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32')
|
|
|
|
|
w_var = paddle.randn((3, 6, 3, 3, 3), dtype='float32')
|
|
|
|
|
|
|
|
|
|
paddle.disable_static()
|
|
|
|
|
|
|
|
|
|
x_var = paddle.to_tensor(x)
|
|
|
|
|
w_var = paddle.to_tensor(w)
|
|
|
|
|
y_var = F.conv_transpose3d(x_var, w_var)
|
|
|
|
|
y_np = y_var.numpy()
|
|
|
|
|
print(y_np.shape)
|
|
|
|
|
|
|
|
|
|
print(y_np.shape)
|
|
|
|
|
# (2, 6, 10, 10, 10)
|
|
|
|
|
"""
|
|
|
|
|
# entry checks
|
|
|
|
|