pandera.api.tensordict.model.TensorDictModel¶
- class pandera.api.tensordict.model.TensorDictModel(*args: Any, **kwargs: Any)[source]¶
Declarative TensorDict schema using class definitions.
Fields are defined using
pa.Fielddirectly in type annotations. Use PyTorch dtypes(e.g., torch.float32, torch.int64) to specify the expected data type:
- Example:
>>> import torch >>> import pandera.tensordict as pa
>>> class MySchema(pa.TensorDictModel): ... observation: torch.float32 = pa.Field(shape=(None, 10)) ... action: torch.int64 = pa.Field(shape=(None,)) ... ... class Config: ... batch_size = (32,)
>>> schema = MySchema.to_schema()
Validate data against model schema.
Methods
- classmethod build_schema_(**kwargs)[source]¶
Create TensorDictSchema from model class.
- Return type:
- Returns:
TensorDictSchema with fields converted to Tensor components.
- classmethod to_schema()[source]¶
Create
TensorDictSchemafrom theTensorDictModel.- Return type: