1D convolution with separable filters. Arguments: x: input tensor depthwise_kernel: convolution kernel for the depthwise convolution. pointwise_kernel: kernel for the 1x1 convolution. strides: stride integer. padding: string, `"same"` or `"valid"`. data_format:
(x,
depthwise_kernel,
pointwise_kernel,
strides=1,
padding='valid',
data_format=None,
dilation_rate=1)
| 4835 | |
| 4836 | |
| 4837 | def separable_conv1d(x, |
| 4838 | depthwise_kernel, |
| 4839 | pointwise_kernel, |
| 4840 | strides=1, |
| 4841 | padding='valid', |
| 4842 | data_format=None, |
| 4843 | dilation_rate=1): |
| 4844 | """1D convolution with separable filters. |
| 4845 | |
| 4846 | Arguments: |
| 4847 | x: input tensor |
| 4848 | depthwise_kernel: convolution kernel for the depthwise convolution. |
| 4849 | pointwise_kernel: kernel for the 1x1 convolution. |
| 4850 | strides: stride integer. |
| 4851 | padding: string, `"same"` or `"valid"`. |
| 4852 | data_format: string, `"channels_last"` or `"channels_first"`. |
| 4853 | dilation_rate: integer dilation rate. |
| 4854 | |
| 4855 | Returns: |
| 4856 | Output tensor. |
| 4857 | |
| 4858 | Raises: |
| 4859 | ValueError: if `data_format` is neither `channels_last` or |
| 4860 | `channels_first`. |
| 4861 | """ |
| 4862 | if data_format is None: |
| 4863 | data_format = image_data_format() |
| 4864 | if data_format not in {'channels_first', 'channels_last'}: |
| 4865 | raise ValueError('Unknown data_format: ' + str(data_format)) |
| 4866 | |
| 4867 | if isinstance(strides, int): |
| 4868 | strides = (strides,) |
| 4869 | if isinstance(dilation_rate, int): |
| 4870 | dilation_rate = (dilation_rate,) |
| 4871 | |
| 4872 | x, tf_data_format = _preprocess_conv1d_input(x, data_format) |
| 4873 | padding = _preprocess_padding(padding) |
| 4874 | if not isinstance(strides, tuple): |
| 4875 | strides = tuple(strides) |
| 4876 | if tf_data_format == 'NWC': |
| 4877 | spatial_start_dim = 1 |
| 4878 | strides = (1,) + strides * 2 + (1,) |
| 4879 | else: |
| 4880 | spatial_start_dim = 2 |
| 4881 | strides = (1, 1) + strides * 2 |
| 4882 | x = array_ops.expand_dims(x, spatial_start_dim) |
| 4883 | depthwise_kernel = array_ops.expand_dims(depthwise_kernel, 0) |
| 4884 | pointwise_kernel = array_ops.expand_dims(pointwise_kernel, 0) |
| 4885 | dilation_rate = (1,) + dilation_rate |
| 4886 | |
| 4887 | x = nn.separable_conv2d( |
| 4888 | x, |
| 4889 | depthwise_kernel, |
| 4890 | pointwise_kernel, |
| 4891 | strides=strides, |
| 4892 | padding=padding, |
| 4893 | rate=dilation_rate, |
| 4894 | data_format=tf_data_format) |
nothing calls this directly
no test coverage detected