base¶
Interface contract for our models.
- class mfai.pytorch.models.base.AutoPaddingModel[source]¶
Bases:
ABC- abstract validate_input_shape(input_shape)[source]¶
- Given an input shape, verifies whether the inputs fit with the
calling model’s specifications.
- Parameters:
input_shape (Size) – The shape of the input data, excluding any batch dimension and channel dimension. For example, for a batch of 2D tensors of shape [B,C,W,H], [W,H] should be passed. For 3D data instead of shape [B,C,W,H,D], instead, [W,H,D] should be passed.
- Returns:
- Returns a tuple where the first element is a boolean signaling whether the given input shape
already fits the model’s requirements. If that value is False, the second element contains the closest shape that fits the model, otherwise it will be None.
- Return type:
- class mfai.pytorch.models.base.ModelABC[source]¶
Bases:
ABC- abstract property features_last: bool¶
Indicates if the features are the last dimension in the input/output tensors. Conv and ViT typically have features as the second dimension (Batch, Features, …) versus GNNs for which features are the last dimension (Batch, …, Features).
- abstract property num_spatial_dims: int¶
Returns the number of spatial dimensions of the instanciated model.
- abstract property supported_num_spatial_dims: tuple[int, ...]¶
Returns the number of input spatial dimensions supported by the model. A 2d vision model supporting (H, W) should return (2,). A model supporting both 2d and 3d inputs (by settings) should return (2, 3). Once instanciated the model will be in 2d OR 3d mode.
- class mfai.pytorch.models.base.ModelType(value)[source]¶
Bases:
EnumEnum to classify the models depending on their architecture family. Having the model expose this as an attributee facilitates top level code: reshaping input tensors, iterating only on a subset of models, etc.
- CONVOLUTIONAL = 2¶
- GRAPH = 1¶
- IDENTITY = 7¶
- LLM = 4¶
- MULTIMODAL_LLM = 5¶
- PANGU = 6¶
- VISION_TRANSFORMER = 3¶