scimba_torch.approximation_space.abstract_space¶
Defines an abstract class for an approximation space.
Classes
| 
 | Abstract class for an approximation space. | 
- class AbstractApproxSpace(nb_unknowns, **kwargs)[source]¶
- Bases: - ABC- Abstract class for an approximation space. - This class provides the base structure for approximation spaces, including methods for gradient computation, evaluation, and handling degrees of freedom. - Parameters:
- nb_unknowns ( - int) – Number of unknowns in the approximation space.
- **kwargs – Additional keyword arguments. 
 
 - 
type_space: str¶
- Type of the approximation space. 
 - 
integrator: TensorizedSampler¶
- An integrator for tensorized sampling. 
 - 
ndof: int¶
- Number of degrees of freedom. 
 - 
best_approx: dict¶
- dictionary to store the best approximation state. 
 - grad(w, y)[source]¶
- Computes the gradient of w with respect to y. - Parameters:
- w ( - Tensor|- MultiLabelTensor) – The tensor to differentiate.
- y ( - Tensor|- LabelTensor) – The tensor with respect to which the gradient is computed.
 
- Returns:
- The gradient tensor. 
- Return type:
- torch.Tensor | Generator[torch.Tensor, None, None] 
- Raises:
- ValueError – If w and y are not compatible tensor types or shapes. 
 
 - abstract evaluate(*args, with_last_layer=True)[source]¶
- Evaluates the approximation space. - Parameters:
- *args ( - LabelTensor) – Input tensors for evaluation.
- with_last_layer ( - bool) – Whether to include the last layer in evaluation. (Default value = True)
 
- Return type:
- Returns:
- The result of the evaluation. 
 
 - abstract jacobian(*args)[source]¶
- Computes the Jacobian of the approximation space. - Parameters:
- *args ( - LabelTensor) – Input tensors for Jacobian computation.
- Return type:
- Tensor
- Returns:
- The Jacobian tensor. 
 
 - abstract set_dof(theta, flag_scope)[source]¶
- Sets the degrees of freedom for the approximation space. - Parameters:
- theta ( - Tensor) – Tensor representing the degrees of freedom.
- flag_scope ( - str) – Scope flag for setting degrees of freedom.
 
- Return type:
- None
 
 - abstract get_dof(flag_scope, flag_format)[source]¶
- Gets the degrees of freedom for the approximation space. - Parameters:
- flag_scope ( - str) – Scope flag for getting degrees of freedom.
- flag_format ( - str) – Format flag for the degrees of freedom.
 
- Return type:
- Tensor|- list
- Returns:
- The degrees of freedom. 
 
 - dict_for_save()[source]¶
- Returns a dictionary representing the space that can be stored/saved. - Return type:
- dict
- Returns:
- A dictionary representing the space. 
 
 - load_from_dict(checkpoint)[source]¶
- Restores the space from a dictionary. - Parameters:
- checkpoint ( - dict) – dictionary containing the state to restore.
- Return type:
- None