tf.keras.ops.separable_conv  |  TensorFlow v2.16.1 (original) (raw)

tf.keras.ops.separable_conv

General N-D separable convolution.

View aliases

Main aliases

tf.keras.ops.nn.separable_conv

tf.keras.ops.separable_conv(
    inputs,
    depthwise_kernel,
    pointwise_kernel,
    strides=1,
    padding='valid',
    data_format=None,
    dilation_rate=1
)

This ops supports 1D and 2D separable convolution. separable_conv is a depthwise conv followed by a pointwise conv.

Args
inputs Tensor of rank N+2. inputs has shape(batch_size,) + inputs_spatial_shape + (num_channels,) ifdata_format="channels_last", or(batch_size, num_channels) + inputs_spatial_shape ifdata_format="channels_first".
depthwise_kernel Tensor of rank N+2. depthwise_kernel has shape [kernel_spatial_shape, num_input_channels, num_channels_multiplier],num_input_channels should match the number of channels ininputs.
pointwise_kernel Tensor of rank N+2. pointwise_kernel has shape(*ones_like(kernel_spatial_shape), num_input_channels * num_channels_multiplier, num_output_channels).
strides int or int tuple/list of len(inputs_spatial_shape), specifying the strides of the convolution along each spatial dimension. If strides is int, then every spatial dimension shares the same strides.
padding string, either "valid" or "same". "valid" means no padding is applied, and "same" results in padding evenly to the left/right or up/down of the input such that output has the same height/width dimension as the input when strides=1.
data_format A string, either "channels_last" or "channels_first".data_format determines the ordering of the dimensions in the inputs. If data_format="channels_last", inputs is of shape(batch_size, ..., channels) while ifdata_format="channels_first", inputs is of shape(batch_size, channels, ...).
dilation_rate int or int tuple/list of len(inputs_spatial_shape), specifying the dilation rate to use for dilated convolution. Ifdilation_rate is int, then every spatial dimension shares the same dilation_rate.
Returns
A tensor of rank N+2, the result of the depthwise conv operation.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.

Last updated 2024-06-07 UTC.