faninsar.NSBAS.inversion.batch_lstsq#
- faninsar.NSBAS.inversion.batch_lstsq(G: np.ndarray | torch.Tensor, d: np.ndarray | torch.Tensor, dtype: torch.dtype = torch.float64, device: str | torch.device | None = None, verbose: bool = True, tqdm_args: dict | None = None, return_numpy: bool = True) NDArray[np.floating] | torch.Tensor[source]#
Batch least-squares solver for solving the least squares problem.
- Parameters:
G (np.ndarray | torch.Tensor) – model field matrix with shape of (n_im, n_param) or (n_pt, n_im, n_param). If G is 3D, the first dimension is the G matrix for every pixel.
d (np.ndarray | torch.Tensor) – data field matrix with shape of (n_im, n_pt).
dtype (torch.dtype, optional) – dtype of torch.tensor used for computation
device (Optional[str | torch.device], optional) – device of torch.tensor used for computation. If None, use GPU if available, otherwise use CPU.
verbose (bool, optional) – If True, show progress bar, by default True
tqdm_args (dict, optional) – Arguments to be passed to tqdm.tqdm Object for progress bar.
return_numpy (bool, optional) – If True, return a numpy array, otherwise return a torch tensor.
- Returns:
X – (n_im x n_pt) matrix that minimizes norm(M*(GX - d)). If return_numpy is True, return a numpy array, otherwise return a torch tensor.
- Return type:
np.ndarray | torch.Tensor