ยป Keras API reference / KerasCV / Layers / Preprocessing layers / ChannelShuffle layer

ChannelShuffle layer

[source]

ChannelShuffle class

keras_cv.layers.ChannelShuffle(groups=3, seed=None, **kwargs)

Shuffle channels of an input image.

Input shape

The expected images should be [0-255] pixel ranges. 3D (unbatched) or 4D (batched) tensor with shape: (..., height, width, channels), in "channels_last" format

Output shape

3D (unbatched) or 4D (batched) tensor with shape: (..., height, width, channels), in "channels_last" format

Arguments

  • groups: Number of groups to divide the input channels. Default 3.
  • seed: Integer. Used to create a random seed.

Call arguments

  • inputs: Tensor representing images of shape (batch_size, width, height, channels), with dtype tf.float32 / tf.uint8, or (width, height, channels), with dtype tf.float32 / tf.uint8
  • training: A boolean argument that determines whether the call should be run in inference mode or training mode. Default: True.

Usage:

(images, labels), _ = tf.keras.datasets.cifar10.load_data()
channel_shuffle = keras_cv.layers.ChannelShuffle()
augmented_images = channel_shuffle(images)