Data Condition#
Module for the Data Condition class.
- class DataCondition(input, conditional_variables=None)[source]#
Bases:
BaseConditionThe class
DataConditiondefines an unsupervised condition based oninputdata. This condition is typically used in data-driven problems, where the model is trained using a custom unsupervised loss determined by the chosenBaseSolver, while leveraging the provided data during training. Optionalconditional_variablescan be specified when the model depends on additional parameters.- Example:
>>> from pina import Condition, LabelTensor >>> import torch
>>> pts = LabelTensor(torch.randn(100, 2), labels=["x", "y"]) >>> cond_vars = LabelTensor(torch.randn(100, 1), labels=["w"]) >>> condition = Condition(input=pts, conditional_variables=cond_vars)
Initialization of the
BaseConditionclass.- Parameters:
kwargs (dict) – The keyword arguments representing the data to be stored in the condition.
- store_data(**kwargs)[source]#
Store the input data and the conditional variables in a dictionary-like structure.
- Parameters:
kwargs (dict) – The keyword arguments containing the data to be stored.
- Returns:
A dictionary-like structure containing the stored data.
- Return type:
- evaluate(batch, solver)[source]#
Evaluate the residual of the condition on the given batch using the solver.
This method computes the non-aggregated, element-wise residual of the condition. A forward pass of the solver’s model is performed on the input samples, and the condition residual is evaluated accordingly.
The returned tensor is not reduced, preserving the per-sample residual values.
- Parameters:
batch (dict) – The batch containing the data required by the condition evaluation.
solver (BaseSolver) – The solver used to perform the forward pass and compute the residual. The solver provides access to the model and its parameters, which may be necessary for evaluating the condition residual.
- Returns:
The non-aggregated residual tensor.
- Return type:
- property conditional_variables#
The conditional variables associated with the condition.
- Returns:
The conditional variables.
- Return type:
torch.Tensor | LabelTensor | None
- property input#
The input data associated with the condition.
- Returns:
The input data.
- Return type:
torch.Tensor | LabelTensor | Graph | Data | list[Graph] | list[Data] | tuple[Graph] | tuple[Data]