当前位置:网站首页>tf.compat.v1.pad
tf.compat.v1.pad
2022-06-21 05:50:00 【Wanderer001】
参考 tf.compat.v1.pad - 云+社区 - 腾讯云
Pads a tensor.
tf.compat.v1.pad(
tensor,
paddings,
mode='CONSTANT',
name=None,
constant_values=0
)
This operation pads a tensor according to the paddings you specify. paddings is an integer tensor with shape [n, 2], where n is the rank of tensor.
For each dimension D of input, paddings[D, 0] indicates how many values to add before the contents of tensor in that dimension, and paddings[D, 1] indicates how many values to add after the contents of tensor in that dimension.
If mode is "REFLECT" then both paddings[D, 0] and paddings[D, 1] must be no greater than tensor.dim_size(D) - 1.
If mode is "SYMMETRIC" then both paddings[D, 0] and paddings[D, 1] must be no greater than tensor.dim_size(D).
The padded size of each dimension D of the output is:
paddings[D, 0] + tensor.dim_size(D) + paddings[D, 1]
For example:
t = tf.constant([[1, 2, 3], [4, 5, 6]])
paddings = tf.constant([[1, 1,], [2, 2]])
# 'constant_values' is 0.
# rank of 't' is 2.
tf.pad(t, paddings, "CONSTANT") # [[0, 0, 0, 0, 0, 0, 0],
# [0, 0, 1, 2, 3, 0, 0],
# [0, 0, 4, 5, 6, 0, 0],
# [0, 0, 0, 0, 0, 0, 0]]
tf.pad(t, paddings, "REFLECT") # [[6, 5, 4, 5, 6, 5, 4],
# [3, 2, 1, 2, 3, 2, 1],
# [6, 5, 4, 5, 6, 5, 4],
# [3, 2, 1, 2, 3, 2, 1]]
tf.pad(t, paddings, "SYMMETRIC") # [[2, 1, 1, 2, 3, 3, 2],
# [2, 1, 1, 2, 3, 3, 2],
# [5, 4, 4, 5, 6, 6, 5],
# [5, 4, 4, 5, 6, 6, 5]]
Args:
tensor: ATensor.paddings: ATensorof typeint32.mode: One of "CONSTANT", "REFLECT", or "SYMMETRIC" (case-insensitive)name: A name for the operation (optional).constant_values: In "CONSTANT" mode, the scalar pad value to use. Must be same type astensor.
Returns:
- A
Tensor. Has the same type astensor.
Raises:
ValueError: When mode is not one of "CONSTANT", "REFLECT", or "SYMMETRIC".
边栏推荐
- Dosbox installation
- Touch chip applied in touch screen of washing machine
- Excel列数字索引转字符索引
- CANopen cob-id enable PDO function
- Things to think about before using mysqldump
- el-table去掉滚动条和斑马纹颜色修改
- RTOS组的嵌入式开发经历
- ReturnType
- 新零售品牌“三只松鼠”遇挫,摆脱困境的两大方法
- Base64 format images are converted into file format images and uploaded to the server
猜你喜欢

Oraclelinux6.5 graphical installation Oracle11g

Picture steganography: Method 1

图片隐写术:方法1

萤石云应用

成立时间用了时间插件,但在网页上修改参数的时候,如果未修改时间第一次保存会报错,第二次才行

浅谈美国ESS音频DAC解码芯片ES9023

Touch chip applied in touch screen of washing machine

Transformer模型实现与解析

Small program design scheme for appointment of beauty agencies

完善业务细节必填项的确定,根据返回的状态码回显错误信息时,回显的信息与预期不符
随机推荐
C语言课程设计(服装管理系统详解)
GCC警告选项理解
Laravel
平衡二叉树详解 通俗易懂
Embedded programming complexity
Embedded development experience of RTOS group
Small program design scheme for appointment of beauty agencies
Attack and defense world PHP_ rce
Importance of variables in code
Use of mysqldump in MySQL
Subtitle, key frame animation and sound processing in PR
应用在电子产品背光显示中的模拟环境光传感芯片
CANopen COB-ID 使能PDO功能
Q & A: issues related to "micro build low code" billing
Analog ambient light sensor chip used in backlight display of electronic products
SSH copy ID batch password free script
基于注意力的seq2seq模型
Research and Analysis on the current situation of China's video conference transcription market and forecast report on its development prospects (2022)
MySQL MySQL mysqldump data backup and incremental backup
VMware new oraclelinux6.5 virtual machine