未验证 提交 f27d1bee 编写于 作者: C cnn 提交者: GitHub

rename conv_transposeXd-->convXd_transpose (#28198)

上级 7bfd799d
...@@ -92,7 +92,7 @@ class Conv1DTransposeTestCase(unittest.TestCase): ...@@ -92,7 +92,7 @@ class Conv1DTransposeTestCase(unittest.TestCase):
"weight", self.weight_shape, dtype=self.dtype) "weight", self.weight_shape, dtype=self.dtype)
b_var = fluid.data( b_var = fluid.data(
"bias", (self.out_channels, ), dtype=self.dtype) "bias", (self.out_channels, ), dtype=self.dtype)
y_var = F.conv_transpose1d( y_var = F.conv1d_transpose(
x_var, x_var,
w_var, w_var,
None if self.no_bias else b_var, None if self.no_bias else b_var,
......
...@@ -128,7 +128,7 @@ class Conv2DTransposeTestCase(unittest.TestCase): ...@@ -128,7 +128,7 @@ class Conv2DTransposeTestCase(unittest.TestCase):
else: else:
output_size = self.output_size output_size = self.output_size
y_var = F.conv_transpose2d( y_var = F.conv2d_transpose(
x_var, x_var,
w_var, w_var,
None if self.no_bias else b_var, None if self.no_bias else b_var,
......
...@@ -119,7 +119,7 @@ class Conv3DTransposeTestCase(unittest.TestCase): ...@@ -119,7 +119,7 @@ class Conv3DTransposeTestCase(unittest.TestCase):
"weight", self.weight_shape, dtype=self.dtype) "weight", self.weight_shape, dtype=self.dtype)
b_var = fluid.data( b_var = fluid.data(
"bias", (self.num_filters, ), dtype=self.dtype) "bias", (self.num_filters, ), dtype=self.dtype)
y_var = F.conv_transpose3d( y_var = F.conv3d_transpose(
x_var, x_var,
w_var, w_var,
None if self.no_bias else b_var, None if self.no_bias else b_var,
......
...@@ -111,7 +111,7 @@ class TestFunctionalConv2D(TestCase): ...@@ -111,7 +111,7 @@ class TestFunctionalConv2D(TestCase):
"weight", self.weight.shape, dtype=self.dtype) "weight", self.weight.shape, dtype=self.dtype)
if not self.no_bias: if not self.no_bias:
bias = fluid.data("bias", self.bias.shape, dtype=self.dtype) bias = fluid.data("bias", self.bias.shape, dtype=self.dtype)
y = F.conv_transpose2d( y = F.conv2d_transpose(
x, x,
weight, weight,
None if self.no_bias else bias, None if self.no_bias else bias,
...@@ -134,7 +134,7 @@ class TestFunctionalConv2D(TestCase): ...@@ -134,7 +134,7 @@ class TestFunctionalConv2D(TestCase):
x = dg.to_variable(self.input) x = dg.to_variable(self.input)
weight = dg.to_variable(self.weight) weight = dg.to_variable(self.weight)
bias = None if self.no_bias else dg.to_variable(self.bias) bias = None if self.no_bias else dg.to_variable(self.bias)
y = F.conv_transpose2d( y = F.conv2d_transpose(
x, x,
weight, weight,
bias, bias,
...@@ -215,7 +215,7 @@ class TestFunctionalConv2DError(TestCase): ...@@ -215,7 +215,7 @@ class TestFunctionalConv2DError(TestCase):
"weight", self.weight_shape, dtype=self.dtype) "weight", self.weight_shape, dtype=self.dtype)
if not self.no_bias: if not self.no_bias:
bias = fluid.data("bias", self.bias_shape, dtype=self.dtype) bias = fluid.data("bias", self.bias_shape, dtype=self.dtype)
y = F.conv_transpose2d( y = F.conv2d_transpose(
x, x,
weight, weight,
None if self.no_bias else bias, None if self.no_bias else bias,
......
...@@ -113,7 +113,7 @@ class TestFunctionalConv3DTranspose(TestCase): ...@@ -113,7 +113,7 @@ class TestFunctionalConv3DTranspose(TestCase):
"weight", self.weight.shape, dtype=self.dtype) "weight", self.weight.shape, dtype=self.dtype)
if not self.no_bias: if not self.no_bias:
bias = fluid.data("bias", self.bias.shape, dtype=self.dtype) bias = fluid.data("bias", self.bias.shape, dtype=self.dtype)
y = F.conv_transpose3d( y = F.conv3d_transpose(
x, x,
weight, weight,
None if self.no_bias else bias, None if self.no_bias else bias,
...@@ -138,7 +138,7 @@ class TestFunctionalConv3DTranspose(TestCase): ...@@ -138,7 +138,7 @@ class TestFunctionalConv3DTranspose(TestCase):
x = dg.to_variable(self.input) x = dg.to_variable(self.input)
weight = dg.to_variable(self.weight) weight = dg.to_variable(self.weight)
bias = None if self.no_bias else dg.to_variable(self.bias) bias = None if self.no_bias else dg.to_variable(self.bias)
y = F.conv_transpose3d( y = F.conv3d_transpose(
x, x,
weight, weight,
bias, bias,
...@@ -222,7 +222,7 @@ class TestFunctionalConv3DTransposeError(TestCase): ...@@ -222,7 +222,7 @@ class TestFunctionalConv3DTransposeError(TestCase):
"weight", self.weight_shape, dtype=self.dtype) "weight", self.weight_shape, dtype=self.dtype)
if not self.no_bias: if not self.no_bias:
bias = fluid.data("bias", self.bias_shape, dtype=self.dtype) bias = fluid.data("bias", self.bias_shape, dtype=self.dtype)
y = F.conv_transpose3d( y = F.conv3d_transpose(
x, x,
weight, weight,
None if self.no_bias else bias, None if self.no_bias else bias,
......
...@@ -73,12 +73,12 @@ from .common import interpolate #DEFINE_ALIAS ...@@ -73,12 +73,12 @@ from .common import interpolate #DEFINE_ALIAS
from .common import upsample #DEFINE_ALIAS from .common import upsample #DEFINE_ALIAS
from .common import bilinear #DEFINE_ALIAS from .common import bilinear #DEFINE_ALIAS
from .conv import conv1d #DEFINE_ALIAS from .conv import conv1d #DEFINE_ALIAS
from .conv import conv_transpose1d #DEFINE_ALIAS from .conv import conv1d_transpose #DEFINE_ALIAS
from .common import linear #DEFINE_ALIAS from .common import linear #DEFINE_ALIAS
from .conv import conv2d #DEFINE_ALIAS from .conv import conv2d #DEFINE_ALIAS
from .conv import conv_transpose2d #DEFINE_ALIAS from .conv import conv2d_transpose #DEFINE_ALIAS
from .conv import conv3d #DEFINE_ALIAS from .conv import conv3d #DEFINE_ALIAS
from .conv import conv_transpose3d #DEFINE_ALIAS from .conv import conv3d_transpose #DEFINE_ALIAS
# from .extension import add_position_encoding #DEFINE_ALIAS # from .extension import add_position_encoding #DEFINE_ALIAS
# from .extension import autoincreased_step_counter #DEFINE_ALIAS # from .extension import autoincreased_step_counter #DEFINE_ALIAS
# from .extension import continuous_value_model #DEFINE_ALIAS # from .extension import continuous_value_model #DEFINE_ALIAS
......
...@@ -15,11 +15,11 @@ from __future__ import print_function ...@@ -15,11 +15,11 @@ from __future__ import print_function
__all__ = [ __all__ = [
'conv1d', 'conv1d',
'conv_transpose1d', 'conv1d_transpose',
'conv2d', 'conv2d',
'conv_transpose2d', 'conv2d_transpose',
'conv3d', 'conv3d',
'conv_transpose3d', 'conv3d_transpose',
] ]
import numpy as np import numpy as np
...@@ -541,7 +541,7 @@ def conv2d(x, ...@@ -541,7 +541,7 @@ def conv2d(x,
return out return out
def conv_transpose1d(x, def conv1d_transpose(x,
weight, weight,
bias=None, bias=None,
stride=1, stride=1,
...@@ -682,7 +682,7 @@ def conv_transpose1d(x, ...@@ -682,7 +682,7 @@ def conv_transpose1d(x,
[[4, 2]]]).astype(np.float32) [[4, 2]]]).astype(np.float32)
x_var = paddle.to_tensor(x) x_var = paddle.to_tensor(x)
w_var = paddle.to_tensor(w) w_var = paddle.to_tensor(w)
y_var = F.conv_transpose1d(x_var, w_var) y_var = F.conv1d_transpose(x_var, w_var)
y_np = y_var.numpy() y_np = y_var.numpy()
print y_np print y_np
...@@ -802,7 +802,7 @@ def conv_transpose1d(x, ...@@ -802,7 +802,7 @@ def conv_transpose1d(x,
return out return out
def conv_transpose2d(x, def conv2d_transpose(x,
weight, weight,
bias=None, bias=None,
stride=1, stride=1,
...@@ -920,7 +920,7 @@ def conv_transpose2d(x, ...@@ -920,7 +920,7 @@ def conv_transpose2d(x,
None by default. None by default.
Returns: Returns:
A Tensor representing the conv_transpose2d, whose A Tensor representing the conv2d_transpose, whose
data type is the same with input and shape is (num_batches, channels, out_h, data type is the same with input and shape is (num_batches, channels, out_h,
out_w) or (num_batches, out_h, out_w, channels). The tensor variable storing out_w) or (num_batches, out_h, out_w, channels). The tensor variable storing
transposed convolution result. transposed convolution result.
...@@ -946,7 +946,7 @@ def conv_transpose2d(x, ...@@ -946,7 +946,7 @@ def conv_transpose2d(x,
x_var = paddle.randn((2, 3, 8, 8), dtype='float32') x_var = paddle.randn((2, 3, 8, 8), dtype='float32')
w_var = paddle.randn((3, 6, 3, 3), dtype='float32') w_var = paddle.randn((3, 6, 3, 3), dtype='float32')
y_var = F.conv_transpose2d(x_var, w_var) y_var = F.conv2d_transpose(x_var, w_var)
y_np = y_var.numpy() y_np = y_var.numpy()
print(y_np.shape) print(y_np.shape)
...@@ -1242,7 +1242,7 @@ def conv3d(x, ...@@ -1242,7 +1242,7 @@ def conv3d(x,
return out return out
def conv_transpose3d(x, def conv3d_transpose(x,
weight, weight,
bias=None, bias=None,
stride=1, stride=1,
...@@ -1364,7 +1364,7 @@ def conv_transpose3d(x, ...@@ -1364,7 +1364,7 @@ def conv_transpose3d(x,
None by default. None by default.
Returns: Returns:
A Tensor representing the conv_transpose3d, whose data A Tensor representing the conv3d_transpose, whose data
type is the same with input and shape is (num_batches, channels, out_d, out_h, type is the same with input and shape is (num_batches, channels, out_d, out_h,
out_w) or (num_batches, out_d, out_h, out_w, channels). If act is None, the tensor out_w) or (num_batches, out_d, out_h, out_w, channels). If act is None, the tensor
variable storing the transposed convolution result, and if act is not None, the tensor variable storing the transposed convolution result, and if act is not None, the tensor
...@@ -1391,7 +1391,7 @@ def conv_transpose3d(x, ...@@ -1391,7 +1391,7 @@ def conv_transpose3d(x,
x_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32') x_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32')
w_var = paddle.randn((3, 6, 3, 3, 3), dtype='float32') w_var = paddle.randn((3, 6, 3, 3, 3), dtype='float32')
y_var = F.conv_transpose3d(x_var, w_var) y_var = F.conv3d_transpose(x_var, w_var)
y_np = y_var.numpy() y_np = y_var.numpy()
print(y_np.shape) print(y_np.shape)
......
...@@ -427,7 +427,7 @@ class Conv1DTranspose(_ConvNd): ...@@ -427,7 +427,7 @@ class Conv1DTranspose(_ConvNd):
data_format=data_format) data_format=data_format)
def forward(self, x, output_size=None): def forward(self, x, output_size=None):
out = F.conv_transpose1d( out = F.conv1d_transpose(
x, x,
self.weight, self.weight,
bias=self.bias, bias=self.bias,
...@@ -748,7 +748,7 @@ class Conv2DTranspose(_ConvNd): ...@@ -748,7 +748,7 @@ class Conv2DTranspose(_ConvNd):
else: else:
output_padding = 0 output_padding = 0
out = F.conv_transpose2d( out = F.conv2d_transpose(
x, x,
self.weight, self.weight,
bias=self.bias, bias=self.bias,
...@@ -954,16 +954,16 @@ class Conv3DTranspose(_ConvNd): ...@@ -954,16 +954,16 @@ class Conv3DTranspose(_ConvNd):
**Note**: **Note**:
The conv_transpose3d can be seen as the backward of the conv3d. For conv3d, The conv3d_transpose can be seen as the backward of the conv3d. For conv3d,
when stride > 1, conv3d maps multiple input shape to the same output shape, when stride > 1, conv3d maps multiple input shape to the same output shape,
so for conv_transpose3d, when stride > 1, input shape maps multiple output shape. so for conv3d_transpose, when stride > 1, input shape maps multiple output shape.
If output_size is None, :math:`H_{out} = H^\prime_{out}, :math:`H_{out} = \ If output_size is None, :math:`H_{out} = H^\prime_{out}, :math:`H_{out} = \
H^\prime_{out}, W_{out} = W^\prime_{out}`; else, the :math:`D_{out}` of the output H^\prime_{out}, W_{out} = W^\prime_{out}`; else, the :math:`D_{out}` of the output
size must between :math:`D^\prime_{out}` and :math:`D^\prime_{out} + strides[0]`, size must between :math:`D^\prime_{out}` and :math:`D^\prime_{out} + strides[0]`,
the :math:`H_{out}` of the output size must between :math:`H^\prime_{out}` the :math:`H_{out}` of the output size must between :math:`H^\prime_{out}`
and :math:`H^\prime_{out} + strides[1]`, and the :math:`W_{out}` of the output size must and :math:`H^\prime_{out} + strides[1]`, and the :math:`W_{out}` of the output size must
between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[2]`, between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[2]`,
conv_transpose3d can compute the kernel size automatically. conv3d_transpose can compute the kernel size automatically.
Parameters: Parameters:
in_channels(int): The number of channels in the input image. in_channels(int): The number of channels in the input image.
...@@ -1086,7 +1086,7 @@ class Conv3DTranspose(_ConvNd): ...@@ -1086,7 +1086,7 @@ class Conv3DTranspose(_ConvNd):
else: else:
output_padding = 0 output_padding = 0
out = F.conv_transpose3d( out = F.conv3d_transpose(
x, x,
self.weight, self.weight,
bias=self.bias, bias=self.bias,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册