Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::ops::Conv
#include <nn_ops.h>
Computes a N-D convolution given (N+1+batch_dims)-D input
and (N+2)-D filter
tensors.
Summary
General function for computing a N-D convolution. It is required that 1 <= N <= 3
.
Args:
- scope: A Scope object
- input: Tensor of type T and shape
batch_shape + spatial_shape + [in_channels]
in the case that channels_last_format = true
or shape batch_shape + [in_channels] + spatial_shape
if channels_last_format = false
. spatial_shape is N-dimensional with N=2
or N=3
. Also note that batch_shape
is dictated by the parameter batch_dims
and defaults to 1.
- filter: An
(N+2)-D
Tensor with the same type as input
and shape spatial_filter_shape + [in_channels, out_channels]
, where spatial_filter_shape is N-dimensional with N=2
or N=3
.
- strides: 1-D tensor of length
N+2
. The stride of the sliding window for each dimension of input
. Must have strides[0] = strides[N+1] = 1
.
- padding: The type of padding algorithm to use.
Optional attributes (see Attrs
):
- explicit_paddings: If
padding
is "EXPLICIT"
, the list of explicit padding amounts. For the ith dimension, the amount of padding inserted before and after the dimension is explicit_paddings[2 * i]
and explicit_paddings[2 * i + 1]
, respectively. If padding
is not "EXPLICIT"
, explicit_paddings
must be empty.
- data_format: Used to set the data format. By default
CHANNELS_FIRST
, uses NHWC (2D) / NDHWC (3D)
or if CHANNELS_LAST
, uses NCHW (2D) / NCDHW (3D)
.
- dilations: 1-D tensor of length
N+2
. The dilation factor for each dimension of input
. If set to k > 1
, there will be k-1
skipped cells between each filter element on that dimension. The dimension order is determined by the value of channels_last_format
, see above for details. Dilations in the batch and depth dimensions must be 1.
- batch_dims: A positive integer specifying the number of batch dimensions for the input tensor. Should be less than the rank of the input tensor.
- groups: A positive integer specifying the number of groups in which the input is split along the channel axis. Each group is convolved separately with
filters / groups
filters. The output is the concatenation of all the groups results along the channel axis. Input channels and filters must both be divisible by groups.
Returns:
Output
: A (N+1+batch_dims)-D tensor. The dimension order is determined by the value of channels_last_format
, see below for details.
Public attributes
Public functions
node
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Public static functions
BatchDims
Attrs BatchDims(
int64 x
)
Attrs DataFormat(
StringPiece x
)
Dilations
Attrs Dilations(
const gtl::ArraySlice< int > & x
)
ExplicitPaddings
Attrs ExplicitPaddings(
const gtl::ArraySlice< int > & x
)
Groups
Attrs Groups(
int64 x
)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tensorflow::ops::Conv Class Reference\n\ntensorflow::ops::Conv\n=====================\n\n`#include \u003cnn_ops.h\u003e`\n\nComputes a N-D convolution given (N+1+batch_dims)-D `input` and (N+2)-D `filter` tensors.\n\nSummary\n-------\n\nGeneral function for computing a N-D convolution. It is required that `1 \u003c= N \u003c= 3`.\n\nArgs:\n\n- scope: A [Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: [Tensor](/versions/r2.14/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) of type T and shape `batch_shape + spatial_shape + [in_channels]` in the case that `channels_last_format = true` or shape `batch_shape + [in_channels] + spatial_shape` if `channels_last_format = false`. spatial_shape is N-dimensional with `N=2` or `N=3`. Also note that `batch_shape` is dictated by the parameter `batch_dims` and defaults to 1.\n- filter: An `(N+2)-D`[Tensor](/versions/r2.14/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with the same type as `input` and shape `spatial_filter_shape + [in_channels, out_channels]`, where spatial_filter_shape is N-dimensional with `N=2` or `N=3`.\n- strides: 1-D tensor of length `N+2`. The stride of the sliding window for each dimension of `input`. Must have `strides[0] = strides[N+1] = 1`.\n- padding: The type of padding algorithm to use.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/conv/attrs#structtensorflow_1_1ops_1_1_conv_1_1_attrs)):\n\n- explicit_paddings: If `padding` is `\"EXPLICIT\"`, the list of explicit padding amounts. For the ith dimension, the amount of padding inserted before and after the dimension is `explicit_paddings[2 * i]` and `explicit_paddings[2 * i + 1]`, respectively. If `padding` is not `\"EXPLICIT\"`, `explicit_paddings` must be empty.\n- data_format: Used to set the data format. By default `CHANNELS_FIRST`, uses `NHWC (2D) / NDHWC (3D)` or if `CHANNELS_LAST`, uses `NCHW (2D) / NCDHW (3D)`.\n- dilations: 1-D tensor of length `N+2`. The dilation factor for each dimension of `input`. If set to `k \u003e 1`, there will be `k-1` skipped cells between each filter element on that dimension. The dimension order is determined by the value of `channels_last_format`, see above for details. Dilations in the batch and depth dimensions must be 1.\n- batch_dims: A positive integer specifying the number of batch dimensions for the input tensor. Should be less than the rank of the input tensor.\n- groups: A positive integer specifying the number of groups in which the input is split along the channel axis. Each group is convolved separately with `filters / groups` filters. The output is the concatenation of all the groups results along the channel axis. [Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input) channels and filters must both be divisible by groups.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): A (N+1+batch_dims)-D tensor. The dimension order is determined by the value of `channels_last_format`, see below for details.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [Conv](#classtensorflow_1_1ops_1_1_conv_1a6287e3e083783a8839a1e5945a0c235d)`(const ::`[tensorflow::Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` filter, const gtl::ArraySlice\u003c int \u003e & strides, StringPiece padding)` ||\n| [Conv](#classtensorflow_1_1ops_1_1_conv_1a1a0454a47a9d1b7998b9c19337fdee0c)`(const ::`[tensorflow::Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` filter, const gtl::ArraySlice\u003c int \u003e & strides, StringPiece padding, const `[Conv::Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/conv/attrs#structtensorflow_1_1ops_1_1_conv_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_conv_1a9c0bde16ef271157408f8cad028021a0) | [Operation](/versions/r2.14/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_conv_1ac432deaf8fb63d377d5eae640a9a0308) | `::`[tensorflow::Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_conv_1a54d008d9e6715102204ff35fc4bef53a)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_conv_1a613baefcadce3a2640b1d206bb795a74)`() const ` | |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_conv_1a9bbdcbdb0c3ddec45158a5bba02b5bf0)`() const ` | |\n\n| ### Public static functions ||\n|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|\n| [BatchDims](#classtensorflow_1_1ops_1_1_conv_1a03e8a203323605e33f404e25f52e2cf9)`(int64 x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/conv/attrs#structtensorflow_1_1ops_1_1_conv_1_1_attrs) |\n| [DataFormat](#classtensorflow_1_1ops_1_1_conv_1a478c74724f59413a66761e6058459a84)`(StringPiece x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/conv/attrs#structtensorflow_1_1ops_1_1_conv_1_1_attrs) |\n| [Dilations](#classtensorflow_1_1ops_1_1_conv_1a2bdf588ff1cd3ee5dfa6fae0fafda7ff)`(const gtl::ArraySlice\u003c int \u003e & x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/conv/attrs#structtensorflow_1_1ops_1_1_conv_1_1_attrs) |\n| [ExplicitPaddings](#classtensorflow_1_1ops_1_1_conv_1aeb4e34adfe40a96577628f9c92db0ae5)`(const gtl::ArraySlice\u003c int \u003e & x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/conv/attrs#structtensorflow_1_1ops_1_1_conv_1_1_attrs) |\n| [Groups](#classtensorflow_1_1ops_1_1_conv_1a90dc2a0db109c13a7a5d03b186607e24)`(int64 x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/conv/attrs#structtensorflow_1_1ops_1_1_conv_1_1_attrs) |\n\n| ### Structs ||\n|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::Conv::Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/conv/attrs) | Optional attribute setters for [Conv](/versions/r2.14/api_docs/cc/class/tensorflow/ops/conv#classtensorflow_1_1ops_1_1_conv). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### Conv\n\n```gdscript\n Conv(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input filter,\n const gtl::ArraySlice\u003c int \u003e & strides,\n StringPiece padding\n)\n``` \n\n### Conv\n\n```gdscript\n Conv(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input filter,\n const gtl::ArraySlice\u003c int \u003e & strides,\n StringPiece padding,\n const Conv::Attrs & attrs\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n``` \n\nPublic static functions\n-----------------------\n\n### BatchDims\n\n```text\nAttrs BatchDims(\n int64 x\n)\n``` \n\n### DataFormat\n\n```text\nAttrs DataFormat(\n StringPiece x\n)\n``` \n\n### Dilations\n\n```gdscript\nAttrs Dilations(\n const gtl::ArraySlice\u003c int \u003e & x\n)\n``` \n\n### ExplicitPaddings\n\n```gdscript\nAttrs ExplicitPaddings(\n const gtl::ArraySlice\u003c int \u003e & x\n)\n``` \n\n### Groups\n\n```text\nAttrs Groups(\n int64 x\n)\n```"]]