当前位置:网站首页>初始化层实现
初始化层实现
2022-06-23 06:18:00 【休斯顿凤梨】
应用:
卷积后不改变原图(H,W)
功能:
1.设置location
2.设定指定value
3.设定padding
实现:
#Refer to the official website
import paddle.fluid as fluid
from paddle.fluid.dygraph import Conv2D
from paddle.fluid.initializer import NumpyArrayInitializer
import numpy as np
np.set_printoptions(precision=1)
def main():
x = np.random.rand(6,6).astype(np.float32)
print(x.shape)
print(x)
x = x[np.newaxis,np.newaxis,:,:]
d = 2
with fluid.dygraph.guard(fluid.CPUPlace()):
w = np.ones((1,1,3,3)).astype(np.float32)
pa = fluid.ParamAttr(name = 'conv',initializer=NumpyArrayInitializer(w))
dilated_conv = Conv2D(num_channels=1,
num_filters=1,
filter_size=3,
dilation=d,
padding=0,
stride=1,
param_attr=pa)
print(dilated_conv.weight.numpy().squeeze((0,1)))
print(f'dilation={d}')
x = fluid.dygraph.to_variable(x)
y = dilated_conv(x)
y = y.numpy().squeeze((0,1))
print(y.shape)
print(y)
运行:

边栏推荐
- mongodb 记录
- [STL] summary of map usage of associated containers
- 316. 去除重复字母
- 【项目实训10】箭头的绘制
- 深度学习系列47:styleGAN总结
- cmder
- MySQL redo log redo log
- The illustration shows three handshakes and four waves. Xiaobai can understand them
- Why can't the index of JS array use negative numbers
- Swagger3 integrates oauth2 authentication token
猜你喜欢

MySQL Redo log Redo log

Some difficulties in making web pages

Endnote20 tutorial sharing (unfinished

产品-Axure9(英文版),原型设计后台动态二级菜单显示内容

20220621 Three Conjugates of Dual Quaternions
![[system] right click the desktop icon. After turning around, the Explorer will crash and the desktop will be refreshed](/img/aa/0189beb065fa0d4b625390793cb79b.png)
[system] right click the desktop icon. After turning around, the Explorer will crash and the desktop will be refreshed

别找了诸位 【十二款超级好用的谷歌插件都在这】(确定不来看看?)
![[project training] change of linear arrow](/img/a4/7554522c13684d7590d247f28a6965.png)
[project training] change of linear arrow

XML schema record

Why does TCP protocol shake hands three times instead of two?
随机推荐
315. 计算右侧小于当前元素的个数
如何在 PHP 中进行日期格式验证检查(正则)
Open source oauth2 framework for SSO single sign on
406-双指针(27. 移除元素、977.有序数组的平方、15. 三数之和、18. 四数之和)
mysql 函数
Cetos7 record
cmder
TP6+Redis+think-queue+Supervisor实现进程常驻消息队列/job任务
JS dynamically creates a href circular download file. Only 10 or a fixed number of files can be downloaded
[project training 10] drawing of arrows
深度学习系列46:人脸图像超分GFP-GAN
System permission program cannot access SD card
897. 递增顺序搜索树
【项目实训10】箭头的绘制
What are the pension financial products in 2022? Low risk
The illustration shows three handshakes and four waves. Xiaobai can understand them
MySQL basic query
Detailed explanation of callback function
RFID数据安全性实验:C#可视化实现奇偶校验、CRC冗余校验、海明码校验
数据在内存中的存储方式(C语言)