aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/ops/nn_ops.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/python/ops/nn_ops.py')
-rw-r--r--tensorflow/python/ops/nn_ops.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/tensorflow/python/ops/nn_ops.py b/tensorflow/python/ops/nn_ops.py
index 51ec1c313b..4a8ac42161 100644
--- a/tensorflow/python/ops/nn_ops.py
+++ b/tensorflow/python/ops/nn_ops.py
@@ -278,7 +278,8 @@ def with_space_to_batch(
For N=3, the valid values are "NDHWC" (default) and "NCDHW".
Returns:
- The output Tensor as described above.
+ The output Tensor as described above, dimensions will vary based on the op
+ provided.
Raises:
ValueError: if `padding` is invalid or the arguments are incompatible.
@@ -529,17 +530,16 @@ def convolution(input, filter, # pylint: disable=redefined-builtin
of N `strides` (defaulting [1]*N), this computes for each N-D spatial output
position (x[0], ..., x[N-1]):
+ ```
output[b, x[0], ..., x[N-1], k] =
-
sum_{z[0], ..., z[N-1], q}
-
filter[z[0], ..., z[N-1], q, k] *
padded_input[b,
x[0]*strides[0] + dilation_rate[0]*z[0],
...,
x[N-1]*strides[N-1] + dilation_rate[N-1]*z[N-1],
q]
-
+ ```
where `padded_input` is obtained by zero padding the input using an effective
spatial filter shape of `(spatial_filter_shape-1) * dilation_rate + 1` and
output striding `strides` as described in the
@@ -682,6 +682,7 @@ def pool(input, # pylint: disable=redefined-builtin
0 <= x[i] < output_spatial_shape[i],
0 <= c < num_channels:
+ ```
output[b, x[0], ..., x[N-1], c] =
REDUCE_{z[0], ..., z[N-1]}
input[b,
@@ -689,6 +690,7 @@ def pool(input, # pylint: disable=redefined-builtin
...
x[N-1]*strides[N-1] - pad_before[N-1] + dilation_rate[N-1]*z[N-1],
c],
+ ```
where the reduction function REDUCE depends on the value of `pooling_type`,
and pad_before is defined based on the value of `padding` as described in the
@@ -698,10 +700,12 @@ def pool(input, # pylint: disable=redefined-builtin
In the case that `data_format` starts with `"NC"`, the `input` and output are
simply transposed as follows:
+ ```
pool(input, data_format, **kwargs) =
tf.transpose(pool(tf.transpose(input, [0] + range(2,N+2) + [1]),
**kwargs),
[0, N+1] + range(1, N+1))
+ ```
Args:
input: Tensor of rank N+2, of shape
@@ -740,6 +744,7 @@ def pool(input, # pylint: disable=redefined-builtin
If padding = "SAME":
output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides[i])
+
If padding = "VALID":
output_spatial_shape[i] =
ceil((input_spatial_shape[i] - (window_shape[i] - 1) * dilation_rate[i])
@@ -844,9 +849,14 @@ def atrous_conv2d(value, filters, rate, padding, name=None):
More specifically:
- output[b, i, j, k] = sum_{di, dj, q} filters[di, dj, q, k] *
- value[b, i + rate * di, j + rate * dj, q]
-
+ ```
+ output[batch, height, width, out_channel] =
+ sum_{dheight, dwidth, in_channel} (
+ filters[dheight, dwidth, in_channel, out_channel] *
+ value[batch, height + rate * dheight, width + rate * dwidth, in_channel]
+ )
+ ```
+
Atrous convolution allows us to explicitly control how densely to compute
feature responses in fully convolutional networks. Used in conjunction with
bilinear interpolation, it offers an alternative to `conv2d_transpose` in
@@ -932,6 +942,14 @@ def atrous_conv2d(value, filters, rate, padding, name=None):
Returns:
A `Tensor` with the same type as `value`.
+ Output shape with `'VALID`` padding is:
+
+ [batch, height - 2 * (filter_width - 1),
+ width - 2 * (filter_height - 1), out_channels].
+
+ Output shape with `'SAME'` padding is:
+
+ [batch, height, width, out_channels].
Raises:
ValueError: If input/output depth does not match `filters`' shape, or if