Data Conditions#
- class DataCondition(input, conditional_variables=None)[source]#
Bases:
ConditionInterface
The class
DataCondition
defines an unsupervised condition based oninput
data. This condition is typically used in data-driven problems, where the model is trained using a custom unsupervised loss determined by the chosenSolverInterface
, while leveraging the provided data during training. Optionalconditional_variables
can be specified when the model depends on additional parameters.The class automatically selects the appropriate implementation based on the type of the
input
data. Depending on whether theinput
is a tensor or graph-based data, one of the following specialized subclasses is instantiated:TensorDataCondition
: For cases where theinput
is either atorch.Tensor
or aLabelTensor
object.GraphDataCondition
: For cases where theinput
is either aGraph
orData
object.
- 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
DataCondition
class.- Parameters:
input (torch.Tensor | LabelTensor | Graph | Data | list[Graph] | list[Data] | tuple[Graph] | tuple[Data]) – The input data for the condition.
conditional_variables (torch.Tensor | LabelTensor) – The conditional variables for the condition. Default is
None
.
- class GraphDataCondition(input, conditional_variables=None)[source]#
Bases:
DataCondition
Specialization of the
DataCondition
class for the case whereinput
is either aGraph
object or aData
object.Initialization of the
DataCondition
class.- Parameters:
input (torch.Tensor | LabelTensor | Graph | Data | list[Graph] | list[Data] | tuple[Graph] | tuple[Data]) – The input data for the condition.
conditional_variables (torch.Tensor | LabelTensor) – The conditional variables for the condition. Default is
None
.
- class TensorDataCondition(input, conditional_variables=None)[source]#
Bases:
DataCondition
Specialization of the
DataCondition
class for the case whereinput
is either aLabelTensor
object or atorch.Tensor
object.Initialization of the
DataCondition
class.- Parameters:
input (torch.Tensor | LabelTensor | Graph | Data | list[Graph] | list[Data] | tuple[Graph] | tuple[Data]) – The input data for the condition.
conditional_variables (torch.Tensor | LabelTensor) – The conditional variables for the condition. Default is
None
.