{ }
View source on GitHub |
2D separable convolution layer.
Inherits From: Layer
, Operation
tf.keras.layers.SeparableConv2D(
filters,
kernel_size,
strides=(1, 1),
padding='valid',
data_format=None,
dilation_rate=(1, 1),
depth_multiplier=1,
activation=None,
use_bias=True,
depthwise_initializer='glorot_uniform',
pointwise_initializer='glorot_uniform',
bias_initializer='zeros',
depthwise_regularizer=None,
pointwise_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
depthwise_constraint=None,
pointwise_constraint=None,
bias_constraint=None,
**kwargs
)
This layer performs a depthwise convolution that acts separately on
channels, followed by a pointwise convolution that mixes channels.
If use_bias
is True and a bias initializer is provided,
it adds a bias vector to the output. It then optionally applies an
activation function to produce the final output.
Input shape:
- If
data_format="channels_last"
: A 4D tensor with shape:(batch_size, height, width, channels)
- If
data_format="channels_first"
: A 4D tensor with shape:(batch_size, channels, height, width)
Output shape:
- If
data_format="channels_last"
: A 4D tensor with shape:(batch_size, new_height, new_width, filters)
- If
data_format="channels_first"
: A 4D tensor with shape:(batch_size, filters, new_height, new_width)
Returns | |
---|---|
A 4D tensor representing
activation(separable_conv2d(inputs, kernel) + bias) .
|
Example:
x = np.random.rand(4, 10, 10, 12)
y = keras.layers.SeparableConv2D(3, 4, 3, 2, activation='relu')(x)
print(y.shape)
(4, 4, 4, 4)
Methods
from_config
@classmethod
from_config( config )
Creates a layer from its config.
This method is the reverse of get_config
,
capable of instantiating the same layer from the config
dictionary. It does not handle layer connectivity
(handled by Network), nor weights (handled by set_weights
).
Args | |
---|---|
config
|
A Python dictionary, typically the output of get_config. |
Returns | |
---|---|
A layer instance. |
symbolic_call
symbolic_call(
*args, **kwargs
)