Patches¶
- class keras_mml.layers.misc.Patches[source]¶
Layer that creates patches for an image.
This layer implements the patch extraction algorithm described in An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. Useful for use in Vision Transformers (ViT).
Adapted from the
Patchesclass in the Keras code example Image classification with Vision Transformer.- patch_size¶
Size of the patches.
- __init__(patch_size, **kwargs)[source]¶
Initializes a new instance of the layer.
- Parameters:
patch_size (
int) – Size of the patches.**kwargs – Keyword arguments for
keras.Layer.
- Raises:
ValueError – If the patch size provided is not a positive integer.