TensorFLow 函數翻譯 — tf.nn.conv2d()

tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, data_format=None, name=None)


Computes a 2-D convolution given 4-D input and filter tensors.

通過輸入規定的四維inputfilter計算二維卷積.

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 thr following:

給定一個input的張量[batch, in_height, in_width, in_channels]和一個過濾器 / 內核 張量 [filter_height, filter_width, in_channels, out_channels]后,執行以下操作:

  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 from 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]

  4. 展平filter為一個形狀為[filter_height * filter_width * in_channels, output_channels]的二維矩陣。

  5. input提取圖片集形成一個大小為[batch, out_height, out_width, filter_height * filter_width * in_channels]的虛擬張量。

  6. 循環每個圖片集,對filter矩陣右乘圖片集矢量

在默認的NHWC格式下,詳細的過程是

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].

strides的參數里面必須存在strides[0] = strides[3] = 1這種關系. 在大多數情況下垂直和水平的步幅是一樣的,即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, thr format could be "NCHW", the data storage order of: [batch, in_channels, in_height, in_width].
  • name : A name for the operation(optional)

參數:

  • input : 一個張量. 必須為下列類型之一: half, float32, float64.
  • filter : 一個張量. 必須要跟input的類型一致.
  • strides : 一個整數列表. 長度為4的一維矩陣. input的每一個維度的滑動窗格的步幅. 必須與使用data_format指定的維度具有相同的順序.
  • padding : 字符串類型,可選值有 : "SAME", "VALID". 選擇使用的填充算法的類型.
  • use_cudnn_on_gpu : 一個可選的布爾參數. 默認為 True
  • data_format : 一個可選的字符串參數,可選值有 : "NHWC", "NCHW".默認是"NHWC".
    inputoutput指明數據類型. 使用默認格式"NHWC"時, 數據會被存儲為: [batch, in_height, in_width, in_channels]. 或者,當格式為"NCHW"時, 數據會被存儲為: [batch, in_channels, in_height, in_width].
  • name : 操作的名稱(可選)

Returns:
A Tensor. Has the same type as input.

返回值:
一個張量, 跟input類型相同

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容