Randomly compressed rank-k thin Singular Value Decomposition. This computes the approximate singular value decomposition of a large array. This algorithm is generally faster than the normal algorithm but does not provide exact results. One can balance between performance and accur
(
a,
k,
iterator="power",
n_power_iter=0,
n_oversamples=10,
seed=None,
compute=False,
coerce_signs=True,
)
| 746 | |
| 747 | |
| 748 | def svd_compressed( |
| 749 | a, |
| 750 | k, |
| 751 | iterator="power", |
| 752 | n_power_iter=0, |
| 753 | n_oversamples=10, |
| 754 | seed=None, |
| 755 | compute=False, |
| 756 | coerce_signs=True, |
| 757 | ): |
| 758 | """Randomly compressed rank-k thin Singular Value Decomposition. |
| 759 | |
| 760 | This computes the approximate singular value decomposition of a large |
| 761 | array. This algorithm is generally faster than the normal algorithm |
| 762 | but does not provide exact results. One can balance between |
| 763 | performance and accuracy with input parameters (see below). |
| 764 | |
| 765 | Parameters |
| 766 | ---------- |
| 767 | a: Array |
| 768 | Input array |
| 769 | k: int |
| 770 | Rank of the desired thin SVD decomposition. |
| 771 | iterator: {'power', 'QR'}, default='power' |
| 772 | Define the technique used for iterations to cope with flat |
| 773 | singular spectra or when the input matrix is very large. |
| 774 | n_power_iter: int, default=0 |
| 775 | Number of power iterations, useful when the singular values |
| 776 | decay slowly. Error decreases exponentially as `n_power_iter` |
| 777 | increases. In practice, set `n_power_iter` <= 4. |
| 778 | n_oversamples: int, default=10 |
| 779 | Number of oversamples used for generating the sampling matrix. |
| 780 | This value increases the size of the subspace computed, which is more |
| 781 | accurate at the cost of efficiency. Results are rarely sensitive to this choice |
| 782 | though and in practice a value of 10 is very commonly high enough. |
| 783 | compute : bool |
| 784 | Whether or not to compute data at each use. |
| 785 | Recomputing the input while performing several passes reduces memory |
| 786 | pressure, but means that we have to compute the input multiple times. |
| 787 | This is a good choice if the data is larger than memory and cheap to |
| 788 | recreate. |
| 789 | coerce_signs : bool |
| 790 | Whether or not to apply sign coercion to singular vectors in |
| 791 | order to maintain deterministic results, by default True. |
| 792 | |
| 793 | |
| 794 | Examples |
| 795 | -------- |
| 796 | >>> u, s, v = svd_compressed(x, 20) # doctest: +SKIP |
| 797 | |
| 798 | Returns |
| 799 | ------- |
| 800 | u: Array, unitary / orthogonal |
| 801 | s: Array, singular values in decreasing order (largest first) |
| 802 | v: Array, unitary / orthogonal |
| 803 | |
| 804 | References |
| 805 | ---------- |