cyto_dl.nn.vits.utils module#

cyto_dl.nn.vits.utils.get_positional_embedding(num_patches: Sequence[int], emb_dim: int, use_cls_token: bool = True, learnable: bool = True)[source]#

Generate a positional embedding (with or without a cls token) for a given number of patches and embedding dimension.

Can be either learnable or fixed.

cyto_dl.nn.vits.utils.match_tuple_dimensions(spatial_dims, tuples)[source]#

Ensure that each element in a list of tuples has the same length as spatial_dims.

If a single element, the element is repeated to match the spatial_dims.

cyto_dl.nn.vits.utils.random_indexes(size: int, device)[source]#
cyto_dl.nn.vits.utils.take_indexes(sequences, indexes)[source]#