Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
3ccee082
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
3ccee082
编写于
9月 28, 2020
作者:
K
Kaipeng Deng
提交者:
GitHub
9月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpy -> paddle in conv & conv_transpose (#27669)
* numpy -> paddle in conv. test=develop
上级
ca289201
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
20 addition
and
52 deletion
+20
-52
python/paddle/nn/functional/conv.py
python/paddle/nn/functional/conv.py
+11
-31
python/paddle/nn/layer/conv.py
python/paddle/nn/layer/conv.py
+9
-21
未找到文件。
python/paddle/nn/functional/conv.py
浏览文件 @
3ccee082
...
@@ -438,20 +438,14 @@ def conv2d(x,
...
@@ -438,20 +438,14 @@ def conv2d(x,
import paddle
import paddle
import paddle.nn.functional as F
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_var = F.conv2d(x_var, w_var)
y_np = y_var.numpy()
y_np = y_var.numpy()
print(y_np.shape)
print(y_np.shape)
# (2, 6, 6, 6)
# (2, 6, 6, 6)
"""
"""
# entry checks
# entry checks
...
@@ -946,20 +940,16 @@ def conv_transpose2d(x,
...
@@ -946,20 +940,16 @@ def conv_transpose2d(x,
Examples:
Examples:
.. code-block:: python
.. code-block:: python
import numpy as np
import paddle
import paddle
import paddle.nn.functional as F
import paddle.nn.functional as F
x
= np.random.randn(2, 3, 8, 8).astype(np.float32
)
x
_var = paddle.randn((2, 3, 8, 8), dtype='float32'
)
w
= np.random.randn(3, 6, 3, 3).astype(np.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_var = F.conv_transpose2d(x_var, w_var)
y_np = y_var.numpy()
y_np = y_var.numpy()
print(y_np.shape)
print(y_np.shape)
# (2, 6, 10, 10)
# (2, 6, 10, 10)
"""
"""
...
@@ -1166,20 +1156,16 @@ def conv3d(x,
...
@@ -1166,20 +1156,16 @@ def conv3d(x,
Examples:
Examples:
.. code-block:: python
.. code-block:: python
import numpy as np
import paddle
import paddle
import paddle.nn.functional as F
import paddle.nn.functional as F
x
= np.random.randn(2, 3, 8, 8, 8).astype(np.float32
)
x
_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32'
)
w
= np.random.randn(6, 3, 3, 3, 3).astype(np.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_var = F.conv3d(x_var, w_var)
y_np = y_var.numpy()
y_np = y_var.numpy()
print(y_np.shape)
print(y_np.shape)
# (2, 6, 6, 6, 6)
# (2, 6, 6, 6, 6)
"""
"""
# entry check
# entry check
...
@@ -1399,22 +1385,16 @@ def conv_transpose3d(x,
...
@@ -1399,22 +1385,16 @@ def conv_transpose3d(x,
Examples:
Examples:
.. code-block:: python
.. code-block:: python
import numpy as np
import paddle
import paddle
import paddle.nn.functional as F
import paddle.nn.functional as F
x
= np.random.randn(2, 3, 8, 8, 8).astype(np.float32
)
x
_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32'
)
w
= np.random.randn(3, 6, 3, 3, 3).astype(np.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_var = F.conv_transpose3d(x_var, w_var)
y_np = y_var.numpy()
y_np = y_var.numpy()
print(y_np.shape)
print(y_np.shape)
# (2, 6, 10, 10, 10)
# (2, 6, 10, 10, 10)
"""
"""
# entry checks
# entry checks
...
...
python/paddle/nn/layer/conv.py
浏览文件 @
3ccee082
...
@@ -534,18 +534,15 @@ class Conv2d(_ConvNd):
...
@@ -534,18 +534,15 @@ class Conv2d(_ConvNd):
.. code-block:: python
.. code-block:: python
import numpy as np
import paddle
import paddle
import paddle.nn as nn
import paddle.nn as nn
x = np.random.uniform(-1, 1, (2, 4, 8, 8)).astype('float32')
paddle.disable_static(
)
x_var = paddle.uniform((2, 4, 8, 8), dtype='float32', min=-1., max=1.
)
x_var = paddle.to_tensor(x)
conv = nn.Conv2d(4, 6, (3, 3))
conv = nn.Conv2d(4, 6, (3, 3))
y_var = conv(x_var)
y_var = conv(x_var)
y_np = y_var.numpy()
y_np = y_var.numpy()
print(y_np.shape)
print(y_np.shape)
# (2, 6, 6, 6)
# (2, 6, 6, 6)
"""
"""
...
@@ -702,17 +699,15 @@ class ConvTranspose2d(_ConvNd):
...
@@ -702,17 +699,15 @@ class ConvTranspose2d(_ConvNd):
.. code-block:: python
.. code-block:: python
import numpy as np
import paddle
import paddle
import paddle.nn as nn
import paddle.nn as nn
x = np.random.uniform(-1, 1, (2, 4, 8, 8)).astype('float32')
paddle.disable_static(
)
x_var = paddle.uniform((2, 4, 8, 8), dtype='float32', min=-1., max=1.
)
x_var = paddle.to_tensor(x)
conv = nn.ConvTranspose2d(4, 6, (3, 3))
conv = nn.ConvTranspose2d(4, 6, (3, 3))
y_var = conv(x_var)
y_var = conv(x_var)
y_np = y_var.numpy()
y_np = y_var.numpy()
print(y_np.shape)
print(y_np.shape)
# (2, 6, 10, 10)
# (2, 6, 10, 10)
"""
"""
...
@@ -856,19 +851,15 @@ class Conv3d(_ConvNd):
...
@@ -856,19 +851,15 @@ class Conv3d(_ConvNd):
.. code-block:: python
.. code-block:: python
import numpy as np
import paddle
import paddle
import paddle.nn as nn
import paddle.nn as nn
x = np.random.uniform(-1, 1, (2, 4, 8, 8, 8)).astype('float32')
paddle.disable_static(
)
x_var = paddle.uniform((2, 4, 8, 8, 8), dtype='float32', min=-1., max=1.
)
x_var = dg.to_variable(x)
conv = nn.Conv3d(4, 6, (3, 3, 3))
conv = nn.Conv3d(4, 6, (3, 3, 3))
y_var = conv(x_var)
y_var = conv(x_var)
y_np = y_var.numpy()
y_np = y_var.numpy()
print(y_np.shape)
print(y_np.shape)
# (2, 6, 6, 6, 6)
# (2, 6, 6, 6, 6)
"""
"""
...
@@ -1042,18 +1033,15 @@ class ConvTranspose3d(_ConvNd):
...
@@ -1042,18 +1033,15 @@ class ConvTranspose3d(_ConvNd):
.. code-block:: python
.. code-block:: python
import numpy as np
import paddle
import paddle
import paddle.nn as nn
import paddle.nn as nn
x = np.random.uniform(-1, 1, (2, 4, 8, 8, 8)).astype('float32')
paddle.disable_static(
)
x_var = paddle.uniform((2, 4, 8, 8, 8), dtype='float32', min=-1., max=1.
)
x_var = paddle.to_tensor(x)
conv = nn.ConvTranspose3d(4, 6, (3, 3, 3))
conv = nn.ConvTranspose3d(4, 6, (3, 3, 3))
y_var = conv(x_var)
y_var = conv(x_var)
y_np = y_var.numpy()
y_np = y_var.numpy()
print(y_np.shape)
print(y_np.shape)
# (2, 6, 10, 10, 10)
# (2, 6, 10, 10, 10)
"""
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录