tf.pad()文档如下,

pad(tensor, paddings, mode='CONSTANT', name=None, constant_values=0)
    Pads a tensor.
    
    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]`

实际使用注意,参数paddings元素数(rank)必须和输入维度一一对应,表示该维度前后填充的层数,文档示例验证如下,

import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)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.
res = tf.pad(t, paddings, "CONSTANT", constant_values=1)  # [[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]]print(sess.run(res))'''
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]]
'''

『TensorFlow』pad图片相关推荐

  1. python 动漫卡通人物图片大全,『TensorFlow』DCGAN生成动漫人物头像_下

    一.计算图效果以及实际代码实现 计算图效果 实际模型实现 相关介绍移步我的github项目. 二.生成器与判别器设计 生成器 相关参量, 噪声向量z维度:100 标签向量y维度:10(如果有的话) 生 ...

  2. 『TensorFlow』DCGAN生成动漫人物头像_下

    『TensorFlow』以GAN为例的神经网络类范式 『cs231n』通过代码理解gan网络&tensorflow共享变量机制_上 『TensorFlow』通过代码理解gan网络_中 一.计算 ...

  3. 『TensorFlow』命令行参数解析

    argparse很强大,但是我们未必需要使用这么繁杂的东西,TensorFlow自己封装了一个简化版本的解析方式,实际上是对argparse的封装 脚本化调用tensorflow的标准范式: impo ...

  4. 『TensorFlow』函数查询列表_张量属性调整

    博客园 首页 新随笔 新文章 联系 订阅 管理 『TensorFlow』函数查询列表_张量属性调整 数据类型转换Casting 操作 描述 tf.string_to_number (string_te ...

  5. 『TensorFlow』专题汇总

    TensorFlow函数查询 『TensorFlow』0.x_&_1.x版本框架改动汇总 『TensorFlow』函数查询列表_数值计算 『TensorFlow』函数查询列表_张量属性调整 『 ...

  6. 『TensorFlow』模型保存和载入方法汇总

    一.TensorFlow常规模型加载方法 保存模型 tf.train.Saver()类,.save(sess, ckpt文件目录)方法 参数名称 功能说明 默认值 var_list Saver中存储变 ...

  7. 『TensorFlow』模型载入方法汇总

    『TensorFlow』第七弹_保存&载入会话_霸王回马 一.TensorFlow常规模型加载方法 保存模型 tf.train.Saver()类,.save(sess, ckpt文件目录)方法 ...

  8. 『TensorFlow』第七弹_保存载入会话_霸王回马

    首更: 由于TensorFlow的奇怪形式,所以载入保存的是sess,把会话中当前激活的变量保存下来,所以必须保证(其他网络也要求这个)保存网络和载入网络的结构一致,且变量名称必须一致,这是caffe ...

  9. 『TensorFlow』通过代码理解gan网络_中

    『cs231n』通过代码理解gan网络&tensorflow共享变量机制_上 上篇是一个尝试生成minist手写体数据的简单GAN网络,之前有介绍过,图片维度是28*28*1,生成器的上采样使 ...

  10. 『TensorFlow』分布式训练_其二_单机多GPU并行GPU模式设定

    建议比对『MXNet』第七弹_多GPU并行程序设计 一.tensorflow GPU设置 GPU指定占用 gpu_options = tf.GPUOptions(per_process_gpu_mem ...

最新文章

  1. 嵌入式系统实验 构建嵌入式Linux系统,《嵌入式系统与开发》构建嵌入式Linux系统-实验报告.doc...
  2. ErWin简单使用说明
  3. yii2 引入php文件,Yii2中YiiBase自动加载类、引用文件方法分析(autoload)
  4. outlook邮箱显示一直启动中_Outlook 2016 无法正常启动,显示“正在处理” 然而处理了好几天也没有处理完...
  5. Halcon初学者知识【19】带paint_的系列算子
  6. 密码(图解密码技术)_第二章_历史上的密码
  7. 小米10谷歌连携失败_Android 11 喜讯!小米 10 率先尝鲜,官方刷机包发布下载
  8. socket 收不到netty客户端消息_Netty开发 —— 首个demo学习
  9. 【剑指 offer】(十九)—— 二叉树镜像
  10. php 二进制 保存文件,PHP打开一个二进制文件,修改了内容如何再保存回去呢?...
  11. 用html 数据库登陆界面设计,登录界面代码_登录界面设计代码_vs登录界面代码-Guide信息网...
  12. 初中计算机flash基本知识,初中信息技术flash课件
  13. Linux下的永中 Office 2004(转)
  14. 如何防止CSRF攻击
  15. Linux电驴客户端,全面介绍Linux安装电驴
  16. 【改写历史】--历史谁书写?谁将改写历史?
  17. 在立创商城上快速制作PCB原理图库
  18. http.cn portal.php,短网址,短网址生成,短链接,网址缩短_ft12.com短网址
  19. gif一键抠图 在线_一款支持智能抠图、钢笔抠图的在线抠图工具上线了 速抠图 sukoutu.com...
  20. document.getElementById(“id”)与$(#id)的区别

热门文章

  1. 《Photoshop 2020从入门到精通》读书笔记1
  2. java题目练习笔记,java 20道、数量关系8道、判断推理8道、智力题8道
  3. 2018TLC大会精彩回顾
  4. 微信支付-商家给小程序用户转账教程(全网最详细JAVA版)
  5. Excel 去除重复行
  6. BCAST是什么意思啊
  7. 最全面的 Fiddler 教程讲解
  8. windows桌面ui开发
  9. 戴尔笔记本电脑PIN码忘了, 怎么办
  10. CadenceAllegro16.6绘图软件使用一