当前位置:网站首页>初始化层实现
初始化层实现
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)
运行:

边栏推荐
- Traversal of binary tree and related knowledge
- 301. 删除无效的括号
- 【日常训练】513. 找树左下角的值
- 产品-Axure9(英文版),原型设计 制作下拉二级菜单
- Summarized benefits
- 数据统计与分析基础 实验一 基本语法及运算
- 318. 最大单词长度乘积
- Run typescript code directly using TS node
- C # how to obtain DPI and real resolution (can solve the problem that has been 96)
- Vs2013 ffmpeg environment configuration and common error handling
猜你喜欢

【STL】pair用法总结
![[STL] summary of pair usage](/img/ba/72697f0f8bf018f1b5884e9cc2be4e.png)
[STL] summary of pair usage

【STL】关联容器之unordered_map用法总结

【STL】顺序容器之deque用法总结

js 判断两个数组增加和减少的元素
![Don't look for [12 super easy-to-use Google plug-ins are here] (are you sure you want to take a look?)](/img/45/3e43faf7aba6741825ccb9719b8445.png)
Don't look for [12 super easy-to-use Google plug-ins are here] (are you sure you want to take a look?)

MySQL MVCC多版本并发控制

994. rotten oranges - non recursive method

407-栈与队列(232.用栈实现队列、225. 用队列实现栈)

Cloud box is deeply convinced to create a smart dual-mode teaching resource sharing platform for Nanjing No. 1 middle school
随机推荐
mongodb 记录
mysql 函数
A small method of debugging equipment serial port information with ADB
Solve the mining virus sshd2 (redis does not set a password and clear the crontab scheduled task)
1161 Merging Linked Lists
295. 数据流的中位数
QT designer cannot modify the window size, and cannot change the size by dragging the window with the mouse
【BULL中文文档】用于在 NodeJS 中处理分布式作业和消息的队列包
Endnote20 tutorial sharing (unfinished
core. What is JS ---kalrry
Project_ Filter to solve Chinese garbled code
在金融行业做数据产品经理是什么体验
WPF command directive and inotifypropertychanged
JS dynamically creates a href circular download file. Only 10 or a fixed number of files can be downloaded
MySQL重做日志 redo log
20220621 Three Conjugates of Dual Quaternions
TP6 安装拓展
Business logic design of physical warehouse and virtual warehouse in middle inventory
322. 零钱兑换
Verilog syntax explanation