未验证 提交 6a9a62c3 编写于 作者: M mls1999725 提交者: GitHub

Update conv3d API (#29205)

* Update conv3d API

* Update nn.py

* Update nn.py

* Update nn.py

* Update nn.py

* Update nn.py

* Update nn.py

* Update nn.py

* Update nn.py
上级 aec05d81
...@@ -1676,7 +1676,7 @@ def conv3d(input, ...@@ -1676,7 +1676,7 @@ def conv3d(input,
W_{out}&= \\frac{(W_{in} + 2 * paddings[2] - (dilations[2] * (W_f - 1) + 1))}{strides[2]} + 1 W_{out}&= \\frac{(W_{in} + 2 * paddings[2] - (dilations[2] * (W_f - 1) + 1))}{strides[2]} + 1
Args: Args:
input (Variable): The input is 5-D Tensor with shape [N, C, D, H, W], the data input (Tensor): The input is 5-D Tensor with shape [N, C, D, H, W], the data
type of input is float16 or float32 or float64. type of input is float16 or float32 or float64.
num_filters(int): The number of filter. It is as same as the output num_filters(int): The number of filter. It is as same as the output
image channel. image channel.
...@@ -1750,11 +1750,19 @@ def conv3d(input, ...@@ -1750,11 +1750,19 @@ def conv3d(input,
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid
import paddle import paddle
import numpy as np
paddle.enable_static() paddle.enable_static()
data = fluid.data(name='data', shape=[None, 3, 12, 32, 32], dtype='float32') data = paddle.static.data(name='data', shape=[None, 3, 12, 32, 32], dtype='float32')
conv3d = fluid.layers.conv3d(input=data, num_filters=2, filter_size=3, act="relu") param_attr = paddle.framework.ParamAttr(name='conv3d.weight', initializer=paddle.nn.initializer.XavierNormal(), learning_rate=0.001)
res = paddle.static.nn.conv3d(input=data, num_filters=2, filter_size=3, act="relu", param_attr=param_attr)
place = paddle.CPUPlace()
exe = paddle.static.Executor(place)
exe.run(paddle.static.default_startup_program())
x = np.random.rand(1, 3, 12, 32, 32).astype("float32")
output = exe.run(feed={"data": x}, fetch_list=[res])
print(output)
""" """
l_type = 'conv3d' l_type = 'conv3d'
...@@ -4101,7 +4109,7 @@ def conv3d_transpose(input, ...@@ -4101,7 +4109,7 @@ def conv3d_transpose(input,
conv3d_transpose can compute the kernel size automatically. conv3d_transpose can compute the kernel size automatically.
Args: Args:
input(Variable): The input is 5-D Tensor with shape [N, C, D, H, W] or [N, D, H, W, C], the data type input(Tensor): The input is 5-D Tensor with shape [N, C, D, H, W] or [N, D, H, W, C], the data type
of input is float32 or float64. of input is float32 or float64.
num_filters(int): The number of the filter. It is as same as the output num_filters(int): The number of the filter. It is as same as the output
image channel. image channel.
...@@ -4184,11 +4192,19 @@ def conv3d_transpose(input, ...@@ -4184,11 +4192,19 @@ def conv3d_transpose(input,
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid
import paddle import paddle
import numpy as np
paddle.enable_static() paddle.enable_static()
data = fluid.data(name='data', shape=[None, 3, 12, 32, 32], dtype='float32') data = paddle.static.data(name='data', shape=[None, 3, 12, 32, 32], dtype='float32')
conv3d_transpose = fluid.layers.conv3d_transpose(input=data, num_filters=2, filter_size=3) param_attr = paddle.framework.ParamAttr(name='conv3d.weight', initializer=paddle.nn.initializer.XavierNormal(), learning_rate=0.001)
res = paddle.static.nn.conv3d_transpose(input=data, num_filters=2, filter_size=3, act="relu", param_attr=param_attr)
place = paddle.CPUPlace()
exe = paddle.static.Executor(place)
exe.run(paddle.static.default_startup_program())
x = np.random.rand(1, 3, 12, 32, 32).astype("float32")
output = exe.run(feed={"data": x}, fetch_list=[res])
print(output)
""" """
assert param_attr is not False, "param_attr should not be False in conv3d_transpose." assert param_attr is not False, "param_attr should not be False in conv3d_transpose."
if data_format not in ['NCDHW', 'NDHWC']: if data_format not in ['NCDHW', 'NDHWC']:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册