mmlearn.datasets.core.modalities.Modality

class Modality(name, modality_specific_properties=None)[source]

Bases: object

A representation of a modality in the library.

This class is used to represent a modality in the library. It contains the name of the modality and the properties that can be associated with it. The properties are dynamically generated based on the name of the modality and can be accessed as attributes of the class.

Parameters:
  • name (str) – The name of the modality.

  • modality_specific_properties (Optional[dict[str, str]], optional, default=None) – Additional properties specific to the modality, by default None

Raises:

ValueError – If the property already exists for the modality or if the format string is invalid.

Methods

Attributes

add_property(name, format_string)[source]

Add a new property to the modality.

Parameters:
  • name (str) – The name of the property.

  • format_string (str) – The format string for the property. The format string should contain a placeholder that will be replaced with the name of the modality when the property is accessed.

Warns:

UserWarning – If the property already exists for the modality. It will overwrite the existing property.

Raises:

ValueError – If format_string is invalid. A valid format string contains at least one placeholder enclosed in curly braces.

Return type:

None

attention_mask: str
ema_embedding: str

Embedding from an Exponential Moving Average (EMA) encoder associated with the modality.

embedding: str

Embedding associated with the modality. This will return name_embedding.

mask: str

Input mask associated with the modality. This will return name_mask.

masked_embedding: str
modality_specific_properties: Optional[dict[str, str]] = None

Other properties specific to the modality.

name: str

The name of the modality.

property properties: dict[str, str]

Return the properties associated with the modality.

target: str

Target/label associated with the modality. This will return name_target.