Conditions#
- class Condition(*args, **kwargs)[source]#
Bases:
object
Represents constraints (such as physical equations, boundary conditions, etc.) that must be satisfied in a given problem. Condition objects are used to formulate the PINA
AbstractProblem
object.There are different types of conditions:
InputTargetCondition
: Defined by specifying both the input and the target of the condition. In this case, the model is trained to produce the target given the input. The input and output data must be one of thetorch.Tensor
,LabelTensor
,Data
, orGraph
. Different implementations exist depending on the type of input and target. For more details, seeInputTargetCondition
.DomainEquationCondition
: Defined by specifying both the domain and the equation of the condition. Here, the model is trained to minimize the equation residual by evaluating it at sampled points within the domain.InputEquationCondition
: Defined by specifying the input and the equation of the condition. In this case, the model is trained to minimize the equation residual by evaluating it at the provided input. The input must be either aLabelTensor
or aGraph
. Different implementations exist depending on the type of input. For more details, seeInputEquationCondition
.DataCondition
: Defined by specifying only the input. In this case, the model is trained with an unsupervised custom loss while using the provided data during training. The input data must be one oftorch.Tensor
,LabelTensor
,Data
, orGraph
. Additionally, conditional variables can be provided when the model depends on extra parameters. These conditional variables must be eithertorch.Tensor
orLabelTensor
. Different implementations exist depending on the type of input. For more details, seeDataCondition
.
- Example:
>>> from pina import Condition >>> condition = Condition( ... input=input, ... target=target ... ) >>> condition = Condition( ... domain=location, ... equation=equation ... ) >>> condition = Condition( ... input=input, ... equation=equation ... ) >>> condition = Condition( ... input=data, ... conditional_variables=conditional_variables ... )
Instantiate the appropriate Condition object based on the keyword arguments passed.
- Raises:
ValueError – If no keyword arguments are passed.
ValueError – If the keyword arguments are invalid.
- Returns:
The appropriate Condition object.
- Return type: