Input Target Condition#

Module for the Input-Target Condition class.

class InputTargetCondition(input, target)[source]#

Bases: BaseCondition

The InputTargetCondition class represents a supervised condition defined by both input and target data. The model is trained to reproduce the target values given the input. Supported data types include torch.Tensor, LabelTensor, Graph, or Data.

Example:

>>> from pina import Condition, LabelTensor
>>> from pina.graph import Graph
>>> import torch
>>> pos = LabelTensor(torch.randn(100, 2), labels=["x", "y"])
>>> edge_index = torch.randint(0, 100, (2, 300))
>>> graph = Graph(pos=pos, edge_index=edge_index)
>>> input = LabelTensor(torch.randn(100, 2), labels=["x", "y"])
>>> condition = Condition(input=input, target=graph)

Initialization of the BaseCondition class.

Parameters:

kwargs (dict) – The keyword arguments representing the data to be stored in the condition.

store_data(**kwargs)[source]#

Store the input and target data 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:

_DataManager

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:

torch.Tensor | LabelTensor

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]

property target#

The target data associated with the condition.

Returns:

The target data.

Return type:

torch.Tensor | LabelTensor | Graph | Data | list[Graph] | list[Data] | tuple[Graph] | tuple[Data]