r"""Computes a 1-D convolution given 3-D input and filter tensors. Given an input tensor of shape [batch, in_width, in_channels] if data_format is "NWC", or [batch, in_channels, in_width] if data_format is "NCW", and a filter / kernel tensor of shape [filter_width, in_channels, ou
(
input, # pylint: disable=redefined-builtin
filters,
stride,
padding,
data_format="NWC",
dilations=None,
name=None)
| 1726 | |
| 1727 | @tf_export("nn.conv1d", v1=[]) |
| 1728 | def conv1d_v2( |
| 1729 | input, # pylint: disable=redefined-builtin |
| 1730 | filters, |
| 1731 | stride, |
| 1732 | padding, |
| 1733 | data_format="NWC", |
| 1734 | dilations=None, |
| 1735 | name=None): |
| 1736 | r"""Computes a 1-D convolution given 3-D input and filter tensors. |
| 1737 | |
| 1738 | Given an input tensor of shape |
| 1739 | [batch, in_width, in_channels] |
| 1740 | if data_format is "NWC", or |
| 1741 | [batch, in_channels, in_width] |
| 1742 | if data_format is "NCW", |
| 1743 | and a filter / kernel tensor of shape |
| 1744 | [filter_width, in_channels, out_channels], this op reshapes |
| 1745 | the arguments to pass them to conv2d to perform the equivalent |
| 1746 | convolution operation. |
| 1747 | |
| 1748 | Internally, this op reshapes the input tensors and invokes `tf.nn.conv2d`. |
| 1749 | For example, if `data_format` does not start with "NC", a tensor of shape |
| 1750 | [batch, in_width, in_channels] |
| 1751 | is reshaped to |
| 1752 | [batch, 1, in_width, in_channels], |
| 1753 | and the filter is reshaped to |
| 1754 | [1, filter_width, in_channels, out_channels]. |
| 1755 | The result is then reshaped back to |
| 1756 | [batch, out_width, out_channels] |
| 1757 | \(where out_width is a function of the stride and padding as in conv2d\) and |
| 1758 | returned to the caller. |
| 1759 | |
| 1760 | Args: |
| 1761 | input: A 3D `Tensor`. Must be of type `float16`, `float32`, or `float64`. |
| 1762 | filters: A 3D `Tensor`. Must have the same type as `input`. |
| 1763 | stride: An int or list of `ints` that has length `1` or `3`. The number of |
| 1764 | entries by which the filter is moved right at each step. |
| 1765 | padding: 'SAME' or 'VALID' |
| 1766 | data_format: An optional `string` from `"NWC", "NCW"`. Defaults to `"NWC"`, |
| 1767 | the data is stored in the order of [batch, in_width, in_channels]. The |
| 1768 | `"NCW"` format stores data as [batch, in_channels, in_width]. |
| 1769 | dilations: An int or list of `ints` that has length `1` or `3` which |
| 1770 | defaults to 1. The dilation factor for each dimension of input. If set to |
| 1771 | k > 1, there will be k-1 skipped cells between each filter element on that |
| 1772 | dimension. Dilations in the batch and depth dimensions must be 1. |
| 1773 | name: A name for the operation (optional). |
| 1774 | |
| 1775 | Returns: |
| 1776 | A `Tensor`. Has the same type as input. |
| 1777 | |
| 1778 | Raises: |
| 1779 | ValueError: if `data_format` is invalid. |
| 1780 | """ |
| 1781 | return conv1d( |
| 1782 | input, # pylint: disable=redefined-builtin |
| 1783 | filters, |
| 1784 | stride, |
| 1785 | padding, |