PatchEmbedding¶
- class keras_mml.layers.core.PatchEmbedding[source]¶
Turns image patches into vectors of fixed size.
The image patches should have come from the
Patcheslayer.This layer could optionally include position information in the embeddings by enabling the
with_positionsattribute.- num_patches¶
Number of patches in each image.
- embedding_dim¶
Embedding dimension.
- use_mml¶
Whether to use a matmul-less projection to embed the patches.
- with_positions¶
Whether to include position information in the embeddings.
- __init__(num_patches, embedding_dim, use_mml=True, with_positions=False, **kwargs)[source]¶
Initializes a new instance of the layer.
- Parameters:
num_patches (
int) – Number of patches in each image.embedding_dim (
int) – Embedding dimension.use_mml (
bool, default:True) – Whether to use a matmul-less projection to embed the patches.with_positions (
bool, default:False) – Whether to include position information in the embeddings.**kwargs – Keyword arguments for
keras.Layer.
- Raises:
ValueError – If the number of patches is not a positive integer.
ValueError – If the embedding dimension is not a positive integer.