scimba_torch.approximation_space.kernelx_space¶
Defines the Kernel-based approximation space and its components.
Classes
|
Exponential kernel approximation space. |
|
Gaussian kernen approximation space. |
|
A nonlinear approximation space using a neural network model. |
|
Multiquadratic kernel approximation space. |
- class GaussianKernel(**kwargs)[source]¶
Bases:
ModuleGaussian kernen approximation space.
- Parameters:
**kwargs (
Any) – Additional arguments for the Gaussian kernel.
- forward(vector_diff, aniso)[source]¶
Compute the Gaussian kernel values.
- Parameters:
vector_diff (
Tensor) – Tensor of shape (num_samples, num_centers, input_dim) representing the difference between input points and kernel centers.aniso (
Tensor) – Tensor of shape (num_centers, input_dim, input_dim) representing the anisotropic transformation matrices for each kernel center.
- Return type:
Tensor- Returns:
- Tensor of shape (num_samples, num_centers) containing the Gaussian kernel
values.
- class ExponentialKernel(**kwargs)[source]¶
Bases:
ModuleExponential kernel approximation space.
- Parameters:
**kwargs (
Any) –Additional arguments for the Exponential kernel.
beta: Shape parameter of the Exponential kernel (default: 2).
- forward(vector_diff, aniso)[source]¶
Compute the Exponential kernel values.
- Parameters:
vector_diff (
Tensor) – Tensor of shape (num_samples, num_centers, input_dim) representing the difference between input points and kernel centers.aniso (
Tensor) – Tensor of shape (num_centers, input_dim, input_dim) representing the anisotropic transformation matrices for each kernel center.
- Return type:
Tensor- Returns:
- Tensor of shape (num_samples, num_centers) containing the Exponential
kernel values.
- class MultiquadraticKernel(**kwargs)[source]¶
Bases:
ModuleMultiquadratic kernel approximation space.
- Parameters:
**kwargs (
Any) –Additional arguments for the Multiquadratic kernel.
beta: Shape parameter of the Multiquadratic kernel (default: 2).
- forward(vector_diff, aniso)[source]¶
Compute the Multiquadratic kernel values.
- Parameters:
vector_diff (
Tensor) – Tensor of shape (num_samples, num_centers, input_dim) representing the difference between input points and kernel centers.aniso (
Tensor) – Tensor of shape (num_centers, input_dim, input_dim) representing the anisotropic transformation matrices for each kernel center.
- Return type:
Tensor- Returns:
- Tensor of shape (num_samples, num_centers) containing the Multiquadratic
kernel values.
- class KernelxSpace(nb_unknowns, nb_parameters, kernel_type, nb_centers, spatial_domain, integrator, **kwargs)[source]¶
Bases:
AbstractApproxSpace,ScimbaModuleA nonlinear approximation space using a neural network model.
This class represents a parametric approximation space, where the solution is modeled by a neural network. It integrates functionality for evaluating the network, setting/retrieving degrees of freedom, and computing the Jacobian.
- Parameters:
nb_unknowns (
int) – Number of unknowns in the approximation problem.nb_parameters (
int) – Number of parameters in the approximation problem.kernel_type (
Module) – The type of kernel to use for the approximation.nb_centers (
int) – Number of centers for the kernel functions.spatial_domain (
VolumetricDomain) – The spatial domain of the problem.integrator (
TensorizedSampler) – Sampler used for integration over the spatial and parameter domains.**kwargs – Additional arguments passed to the neural network model.
- centers: torch.nn.Parameter¶
Centers of the kernel functions, initialized as learnable parameters.
- beta: float¶
Parameter for the kernel functions, controlling their shape and behavior.
- M_aniso: torch.nn.Parameter¶
Anisotropic transformation matrix for the kernel functions, initialized as learnable parameters.
- eps: torch.nn.Parameter¶
Epsilon parameters for the kernel functions, initialized as learnable parameters.
- ndof: int¶
Total number of degrees of freedom in the network.
- forward(features, with_last_layer=True)[source]¶
Forward pass through the kernel model.
- Parameters:
features (
Tensor) – Input tensor with concatenated spatial and parameter data.with_last_layer (
bool) – Whether to apply the final linear layer.
- Return type:
Tensor- Returns:
Output tensor from the kernel model.
- evaluate(x, mu, with_last_layer=True)[source]¶
Evaluate the parametric model for given inputs and parameters.
- Parameters:
x (
LabelTensor) – Input tensor from the spatial domain.mu (
LabelTensor) – Input tensor from the parameter domain.with_last_layer (
bool) – Whether to apply the final linear layer.
- Return type:
- Returns:
Output tensor from the neural network, wrapped with multi-label metadata.
- set_dof(theta, flag_scope='all')[source]¶
Sets the degrees of freedom (DoF) for the neural network.
- Parameters:
theta (
Tensor) – A vector containing the network parameters.flag_scope (
str) – The scope of parameters to return.
- Return type:
None
- get_dof(flag_scope='all', flag_format='list')[source]¶
Retrieves the degrees of freedom (DoF) of the neural network.
- Parameters:
flag_scope (
str) – The scope of parameters to return.flag_format (
str) – The format of the returned parameters.
- Return type:
Tensor- Returns:
Tensor containing the DoF of the network.
- jacobian(x, mu)[source]¶
Compute the Jacobian of the network with respect to its parameters.
- Parameters:
x (
LabelTensor) – Input tensor from the spatial domain.mu (
LabelTensor) – Input tensor from the parameter domain.
- Return type:
Tensor- Returns:
Jacobian matrix of shape (num_samples, out_size, num_params).