mmlearn.modules.layers.embedding.PatchEmbed

class PatchEmbed(img_size=224, patch_size=16, in_chans=3, embed_dim=768)[source]

Bases: Module

Image to Patch Embedding.

This module divides an image into patches and embeds them as a sequence of vectors.

Parameters:
  • img_size (int, optional, default=224) – Size of the input image (assumed to be square).

  • patch_size (int, optional, default=16) – Size of each image patch (assumed to be square).

  • in_chans (int, optional, default=3) – Number of input channels in the image.

  • embed_dim (int, optional, default=768) – Dimension of the output embeddings.

Methods

Attributes

forward(x)[source]

Forward pass to convert an image into patch embeddings.

Return type:

Tensor