当前位置:网站首页>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".
边栏推荐
- Implementation of industrial memory copy function
- 工业级的内存拷贝函数实现
- JS encapsulates functions, and the results are appended after multiple calls
- Splunk Enterprise 8.2.5
- Attention based seq2seq model
- 二叉排序树的基本操作
- Music genre classification based on CNN
- Ironocr 2022.1.0 supports 127 national languages
- 用代码生成器 生成代码后复制完成,在网页上不显示模块
- NFT platform track dark horse takes advantage of the situation
猜你喜欢

Small program design scheme for appointment of beauty agencies

应用在电子产品背光显示中的模拟环境光传感芯片

Distributed transaction of microservices Seata

Oraclelinux6.5 graphical installation Oracle11g

Connection refused : no futher information : localhost/127.0.0.1:6379

Emotron伊爾通軟啟動器維修MSF370/MSF450

Capacitive touch chip used in touch screen of mobile phone

力扣------移除字母异位词后的结果数组

sqli-labs26

Implementation and analysis of transformer model
随机推荐
[UVM basics] three commonly used phase functions: build_ phase/connect_ phase/run_ phase
数据接口请求异常,you have an error in your SQL syntax;check the manual that corresponds to your MYSQL server
应用在电子产品背光显示中的模拟环境光传感芯片
嵌入式编程复杂性
科创人·数智未来私董会第4期:转型的实证-幸存者偏差与盲人摸象
These classic software, which was once very popular, are still fresh in my memory now
LED lamp applied in LED plant lighting
Object. Assign() object merge and object Keys() get the object name
NFT platform track dark horse takes advantage of the situation
利用多核多线程进行程序优化
Canvas制作经典贪吃蛇
Embedded development experience of RTOS group
新零售品牌“三只松鼠”遇挫,摆脱困境的两大方法
Canvas makes classic Snake
Close journal temporary archive in SQLite3
【Grafana】Grafana Mimir在海量时间序列指标中的优化
Attention based seq2seq model
Use of mysqldump in MySQL
VMware new oraclelinux6.5 virtual machine
[open source tutorial] DIY tutorial of step-by-step electric adjustment [Author: I love Laurie, Laurie]