当前位置:网站首页>torch. nn. functional. pad
torch. nn. functional. pad
2022-06-11 08:11:00 【Interval】
For a tensor Fill in . The most typical is the picture , Turned out to be 2*2 Of , Now I want to be 3*3 Of , Then you need to fill , There are many choices at this time , For example, whether to fill in the original top right or bottom left ? Or the top left ? wait .
This function can be used to implement these functions .
torch.nn.functional.pad(input, pad, mode='constant', value=0.0)
We only care about the second parameter pad, Don't worry about anything else .pad It's a tuple , The format is as follows :
(1,1) In the last dimension , Fill in the front 1 individual 0, Back filling 1 individual 0
(1,0) In the last dimension , Fill in the front 1 individual 0, No fill after .
(1,1,1,1) Indicates that the last two dimensions should be filled , And fill up, down, left and right 1 individual 0.
.....
below , According to the above 3 Cases for actual combat :
import torch
import torch.nn.functional as tnf
x = torch.tensor([[1, 2],[ 3,4]])
print(x)
print(tnf.pad(x,(1,1)))# Case study 1
print(tnf.pad(x,(1,0)))# Case study 2
print(tnf.pad(x,(1,1,1,1)))# Case study 3

That started 2*2 How to fill in 3*3 The picture of ? Suppose we fill in the right side and the bottom side 1 individual 0, So that's it :
print(x)
print(tnf.pad(x,(0,1,0,1)))

边栏推荐
- C. Manipulating History(贪心/哈希/思维/好题)
- 用 Keras/TensorFlow 2.9 创建深度学习模型的方法总结
- 2021-10-17
- TypeScript-类型别名
- Summary of knowledge points of customized ViewGroup - continuously updated
- 【 史上最全的ENSP【安装图解】!】
- Typescript header file usage details
- Collation of basic knowledge of intermediate development of Andrews (for interview)
- C language to achieve a simple game - minesweeping
- Typescript namespace
猜你喜欢

Solve valueerror: no model found in config file

Solve notimplementederror: layer XX has arguments in`__ init__` and therefore must override `get_ config`

A detailed explanation of one of the causes of dead loop caused by array out of bounds in C language

嵌入式软件面试问题总结

进程控制:进程等待(回收子进程)

Image data enhancement (translation, rotation, brightness transformation, flipping, adding Gaussian noise, scaling, cropping)

How to make hyperlinks in RichTextBox- How can I make a hyperlink work in a RichTextBox?

放大镜子效果图

Batch splice string

图数据库无缝集成Tushare接口
随机推荐
[transfer] two-way merging and sorting of C language
嵌入式软件面试问题总结
Js学习基础document.write在页面中写一行文字
Typescript enumeration
Post - form data of interface test
TypeScripy-类的基本使用
Three expressions of integers and their storage in memory
Summary of evaluation index knowledge points in target detection: summary of IOU cross overlap unit and map/ap/tp/fp/np
通过ComponentCallbacks2来接收onTrimMemory等回调,并mock对应的场景
860. 柠檬水找零
Several ways to avoid concurrent modification exceptions of lists
C language to achieve a simple game - minesweeping
2022.6.7 特长生模拟
彻底记住ImageView的background和src的区别
Collation of open source modulation identification data set
【案例解读】医疗单据OCR识别助力健康险智能理赔
Return in foreach and break in for
Node error report sorting
Pycrypto packaging error
Development of sylixos SD device driver