tensorflow学习基础篇1——conv2d 函数说明
来源:互联网 发布:淘宝商城运营客服 编辑:程序博客网 时间:2024/05/19 05:02
每次学习新知识总是走马观花,理解不深刻,从现在开始坚持将学习到的东西记录下来,一来方便以后回顾,二来加深理解
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tensorflow ——conv2d
tf.nn.conv2d(input, w, strides, padding)
其中 input 为输入,格式为[batch, height, width, channels], 分别为【输入的批次数量、图像的高(行数)、宽(列数)、通道(彩色为3,灰色为1)】
w 为卷积矩阵,二维、分别为[高,宽】
strides 为滑动窗口尺寸,分别为[1, height, width, 1], 通常 strides[0]=strdes[3]=1,因为一般不会在一个个图像,一个个通道之间滑动
padding 为扩展方式,有两种 vaild 和 same
1)不同的padding方式,VALID是采用丢弃的方式,比如上述的input_width=13,只允许滑动2次,多余的元素全部丢掉
2)SAME的方式,采用的是补全的方式,对于上述的情况,允许滑动3次,但是需要补3个元素,左奇右偶,在左边补一个0,右边补2个0
3) For the SAME
padding, the output height and width are computed as:
out_height = ceil(float(in_height) / float(strides[1]))
out_width = ceil(float(in_width) / float(strides[2]))
For the
VALID
padding, the output height and width are computed as:out_height = ceil(float(in_height - filter_height + 1) / float(strides[1]))
out_width = ceil(float(in_width - filter_width + 1) / float(strides[2]))
tensorflow 中源码如下所示,D:\python3.5\Lib\site-packages\tensorflow\python\ops\gen_nn_ops.py
def conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, data_format=None, name=None): r"""Computes a 2-D convolution given 4-D `input` and `filter` tensors. Given an input tensor of shape `[batch, in_height, in_width, in_channels]` and a filter / kernel tensor of shape `[filter_height, filter_width, in_channels, out_channels]`, this op performs the following: 1. Flattens the filter to a 2-D matrix with shape `[filter_height * filter_width * in_channels, output_channels]`. 2. Extracts image patches from the input tensor to form a *virtual* tensor of shape `[batch, out_height, out_width, filter_height * filter_width * in_channels]`. 3. For each patch, right-multiplies the filter matrix and the image patch vector. In detail, with the default NHWC format, output[b, i, j, k] = sum_{di, dj, q} input[b, strides[1] * i + di, strides[2] * j + dj, q] * filter[di, dj, q, k] Must have `strides[0] = strides[3] = 1`. For the most common case of the same horizontal and vertices strides, `strides = [1, stride, stride, 1]`. Args: input: A `Tensor`. Must be one of the following types: `half`, `float32`, `float64`. filter: A `Tensor`. Must have the same type as `input`. strides: A list of `ints`. 1-D of length 4. The stride of the sliding window for each dimension of `input`. Must be in the same order as the dimension specified with format. padding: A `string` from: `"SAME", "VALID"`. The type of padding algorithm to use. use_cudnn_on_gpu: An optional `bool`. Defaults to `True`. data_format: An optional `string` from: `"NHWC", "NCHW"`. Defaults to `"NHWC"`. Specify the data format of the input and output data. With the default format "NHWC", the data is stored in the order of: [batch, in_height, in_width, in_channels]. Alternatively, the format could be "NCHW", the data storage order of: [batch, in_channels, in_height, in_width]. name: A name for the operation (optional). Returns: A `Tensor`. Has the same type as `input`. """ result = _op_def_lib.apply_op("Conv2D", input=input, filter=filter, strides=strides, padding=padding, use_cudnn_on_gpu=use_cudnn_on_gpu, data_format=data_format, name=name) return result
参考网页:http://stackoverflow.com/questions/34642595/tensorflow-strides-argument
- tensorflow学习基础篇1——conv2d 函数说明
- TensorFlow学习笔记(1)——conv2d函数的padding参数详解
- Tensorflow系列——conv2d的用法
- [TensorFlow 学习笔记-04]卷积函数之tf.nn.conv2d
- TensorFlow-tf.nn.conv2d 函数
- tensorflow学习:tf.nn.conv2d 和 tf.layers.conv2d
- TensorFlow深度学习入门——常用函数说明
- Tensorflow -- tf.nn.conv2d() 函数详解
- TensorFlow(四) tf.nn.conv2d函数
- tensorflow:卷积函数----tf.nn.conv2d
- tensorflow学习:常用函数说明
- Tensorflow函数说明(1)
- TensorFlow学习---tf.nn.conv2d实现卷积操作
- TensorFlow学习笔记(十七)tf.nn.conv2d
- TensorFlow tf.nn.conv2d
- Tensorflow NN.conv2d API
- tensorflow conv2d()参数解析
- Tensorflow函数说明(3)——queue
- CCF
- Mongodb learn 一
- Java线程
- python-opencv函数总结之(一)threshold、adaptiveThreshold、Otsu 二值化
- 包含最小元素的栈
- tensorflow学习基础篇1——conv2d 函数说明
- mysql-5.7.17-winx64安装和配置图片教程
- 归并排序(c++)
- Map集合的四种遍历方式
- Hibernatemplete发现save(),delete()无效
- TCP、HTTP、socket的区别
- 纯php代码打印数据表
- 为 Web 开发者提供的 16 本优秀的 E-BOOK
- [Network Analysis] 复杂网络分析总结