Iterative Solver
- kerch.method.iterative(obj, x0: Tensor, num_iter: int = 50, lr=0.001, verbose: bool = False)[source]
Minimizes to following problem for each point in order to find the preimage:
\[\tilde{\mathbf{x}} = \mathrm{argmin}_{\mathbf{x}} \mathtt{obj}(\mathbf{x}).\]The method optimizes with an SGD algorithm.
- Parameters:
verbose (bool, optional) – Shows the training loop. Defaults to
False.obj – Objective to minimize.
x0 (torch.Tensor [num_points, dim_input]) – Starting value for the optimization.
num_iter (int, optional) – Number of iterations for the optimization process. Defaults to 50.
lr (float, optional) – Learning rate of the optimizer. Defaults to 0.001.
- Returns:
Solution \(\tilde{\mathbf{x}}\)
- Return type:
torch.Tensor [num_points, dim_input]
- kerch.method.iterative_preimage_k(k_image: Tensor, kernel: _BaseKernel, num_iter: int = 50, lr=0.001, light_cache=True, verbose: bool = False) Tensor[source]
Minimizes to following problem for each point in order to find the preimage:
\[\tilde{\mathbf{x}} = \mathrm{argmin}_{\mathbf{x}} \big\lVert \mathtt{k\_image} - \mathtt{kernel.k(x)} \big\rVert_2^2\]The method optimizes with an SGD algorithm.
- Parameters:
verbose (bool, optional) – Shows the training loop. Defaults to
False.k_image (torch.Tensor [num_points, num_idx]) – coefficients in the RKHS to be inverted.
kernel (
kerch.kernel.Kernelinstance.) – kernel on which this RKHS is based.num_iter (int, optional) – Number of iterations for the optimization process. Defaults to 50.
lr (float, optional) – Learning rate of the optimizer. Defaults to 0.001.
light_cache (bool, optional) – Specifies whether the cache has to made lighter during the pre-image to avoid keeping the statistics of each iteration. This results in a speedup. Defaults to
True.
- Returns:
Pre-image
- Return type:
torch.Tensor [num_points, dim_input]
- kerch.method.iterative_preimage_phi(phi_image: Tensor, kernel: _BaseKernel, num_iter: int = 50, lr=0.001, light_cache=True, verbose: bool = False) Tensor[source]
Minimizes to following problem for each point in order to find the preimage:
\[\tilde{\mathbf{x}} = \mathrm{argmin}_{\mathbf{x}} \big\lVert \mathtt{phi\_image} - \mathtt{kernel.phi(x)} \big\rVert_2^2\]The method optimizes with an SGD algorithm.
- Parameters:
verbose (bool, optional) – Shows the training loop. Defaults to
False.phi_image (torch.Tensor [num_points, dim_feature]) – feature map image to be inverted.
kernel (
kerch.kernel.Kernelinstance.) – kernel on which this RKHS is based.num_iter (int, optional) – Number of iterations for the optimization process. Defaults to 50.
lr (float, optional) – Learning rate of the optimizer. Defaults to 0.001.
light_cache (bool, optional) – Specifies whether the cache has to made lighter during the pre-image to avoid keeping the statistics of each iteration. This results in a speedup. Defaults to
True.
- Returns:
Pre-image
- Return type:
torch.Tensor [num_points, dim_feature]