Computes sums of N-D convolutions (actually cross-correlation). This also supports either output striding via the optional `strides` parameter or atrous convolution (also known as convolution with holes or dilated convolution, based on the French word "trous" meaning holes in English) via t
(
input, # pylint: disable=redefined-builtin
filter, # pylint: disable=redefined-builtin
padding,
strides=None,
dilation_rate=None,
name=None,
data_format=None,
filters=None,
dilations=None)
| 786 | |
| 787 | @tf_export(v1=["nn.convolution"]) |
| 788 | def convolution( |
| 789 | input, # pylint: disable=redefined-builtin |
| 790 | filter, # pylint: disable=redefined-builtin |
| 791 | padding, |
| 792 | strides=None, |
| 793 | dilation_rate=None, |
| 794 | name=None, |
| 795 | data_format=None, |
| 796 | filters=None, |
| 797 | dilations=None): |
| 798 | """Computes sums of N-D convolutions (actually cross-correlation). |
| 799 | |
| 800 | This also supports either output striding via the optional `strides` parameter |
| 801 | or atrous convolution (also known as convolution with holes or dilated |
| 802 | convolution, based on the French word "trous" meaning holes in English) via |
| 803 | the optional `dilation_rate` parameter. Currently, however, output striding |
| 804 | is not supported for atrous convolutions. |
| 805 | |
| 806 | Specifically, in the case that `data_format` does not start with "NC", given |
| 807 | a rank (N+2) `input` Tensor of shape |
| 808 | |
| 809 | [num_batches, |
| 810 | input_spatial_shape[0], |
| 811 | ..., |
| 812 | input_spatial_shape[N-1], |
| 813 | num_input_channels], |
| 814 | |
| 815 | a rank (N+2) `filter` Tensor of shape |
| 816 | |
| 817 | [spatial_filter_shape[0], |
| 818 | ..., |
| 819 | spatial_filter_shape[N-1], |
| 820 | num_input_channels, |
| 821 | num_output_channels], |
| 822 | |
| 823 | an optional `dilation_rate` tensor of shape [N] (defaulting to [1]*N) |
| 824 | specifying the filter upsampling/input downsampling rate, and an optional list |
| 825 | of N `strides` (defaulting [1]*N), this computes for each N-D spatial output |
| 826 | position (x[0], ..., x[N-1]): |
| 827 | |
| 828 | ``` |
| 829 | output[b, x[0], ..., x[N-1], k] = |
| 830 | sum_{z[0], ..., z[N-1], q} |
| 831 | filter[z[0], ..., z[N-1], q, k] * |
| 832 | padded_input[b, |
| 833 | x[0]*strides[0] + dilation_rate[0]*z[0], |
| 834 | ..., |
| 835 | x[N-1]*strides[N-1] + dilation_rate[N-1]*z[N-1], |
| 836 | q] |
| 837 | ``` |
| 838 | where b is the index into the batch, k is the output channel number, q is the |
| 839 | input channel number, and z is the N-D spatial offset within the filter. Here, |
| 840 | `padded_input` is obtained by zero padding the input using an effective |
| 841 | spatial filter shape of `(spatial_filter_shape-1) * dilation_rate + 1` and |
| 842 | output striding `strides` as described in the |
| 843 | [comment here](https://tensorflow.org/api_guides/python/nn#Convolution). |
| 844 | |
| 845 | In the case that `data_format` does start with `"NC"`, the `input` and output |