MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / avg_pool1d

Function avg_pool1d

tensorflow/python/ops/nn_ops.py:3725–3766  ·  view source on GitHub ↗

Performs the average pooling on the input. Each entry in `output` is the mean of the corresponding size `ksize` window in `value`. Note internally this op reshapes and uses the underlying 2d operation. Args: input: A 3-D `Tensor` of the format specified by `data_format`. ksize: An

(input, ksize, strides, padding, data_format="NWC", name=None)

Source from the content-addressed store, hash-verified

3723
3724@tf_export("nn.avg_pool1d")
3725def avg_pool1d(input, ksize, strides, padding, data_format="NWC", name=None): # pylint: disable=redefined-builtin
3726 """Performs the average pooling on the input.
3727
3728 Each entry in `output` is the mean of the corresponding size `ksize`
3729 window in `value`.
3730
3731 Note internally this op reshapes and uses the underlying 2d operation.
3732
3733 Args:
3734 input: A 3-D `Tensor` of the format specified by `data_format`.
3735 ksize: An int or list of `ints` that has length `1` or `3`. The size of the
3736 window for each dimension of the input tensor.
3737 strides: An int or list of `ints` that has length `1` or `3`. The stride of
3738 the sliding window for each dimension of the input tensor.
3739 padding: A string, either `'VALID'` or `'SAME'`. The padding algorithm. See
3740 the "returns" section of `tf.nn.convolution` for details.
3741 data_format: An optional string from: "NWC", "NCW". Defaults to "NWC".
3742 name: A name for the operation (optional).
3743
3744 Returns:
3745 A `Tensor` of format specified by `data_format`.
3746 The max pooled output tensor.
3747 """
3748 with ops.name_scope(name, "AvgPool1D", [input]) as name:
3749 if data_format is None:
3750 data_format = "NWC"
3751 channel_index = 1 if data_format.startswith("NC") else 2
3752 ksize = [1] + _get_sequence(ksize, 1, channel_index, "ksize")
3753 strides = [1] + _get_sequence(strides, 1, channel_index, "strides")
3754
3755 expanding_dim = 1 if data_format == "NWC" else 2
3756 data_format = "NHWC" if data_format == "NWC" else "NCHW"
3757
3758 input = array_ops.expand_dims_v2(input, expanding_dim)
3759 result = gen_nn_ops.avg_pool(
3760 input,
3761 ksize=ksize,
3762 strides=strides,
3763 padding=padding,
3764 data_format=data_format,
3765 name=name)
3766 return array_ops.squeeze(result, expanding_dim)
3767
3768
3769@tf_export("nn.avg_pool3d")

Callers

nothing calls this directly

Calls 2

_get_sequenceFunction · 0.70
name_scopeMethod · 0.45

Tested by

no test coverage detected