nitorch_fastmath.stochastic
trapprox
trapprox(matvec, shape=None, moments=None, samples=10, method='rademacher', hutchpp=False, **backend)
Stochastic trace approximation (Hutchinson's estimator)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matvec |
`sparse tensor or callable(tensor) -> tensor`
|
Function that computes the matrix-vector product |
required |
shape |
`sequence[int]`
|
"vector" shape |
None
|
moments |
`int`
|
Number of moments |
1
|
samples |
`int`
|
Number of samples |
10
|
method |
`{'rademacher', 'gaussian'}`
|
Sampling method |
'rademacher'
|
hutchpp |
`bool`
|
Use Hutch++ instead of Hutchinson. /!\ Be aware that it uses more memory. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
trace |
`([moments],) tensor`
|
|
Reference
-
Hutchinson, M.F., 1989. A stochastic estimator of the trace of the influence matrix for Laplacian smoothing splines. Communications in Statistics - Simulation and Computation, 18(3), pp.1059-1076.
@article{hutchinson1989, title={A stochastic estimator of the trace of the influence matrix for Laplacian smoothing splines}, author={Hutchinson, Michael F}, journal={Communications in Statistics-Simulation and Computation}, volume={18}, number={3}, pages={1059--1076}, year={1989}, publisher={Taylor \& Francis} } -
Meyer, R.A., Musco, C., Musco, C. and Woodruff, D.P., 2021. Hutch++: Optimal stochastic trace estimation. Symposium on Simplicity in Algorithms (SOSA) (pp. 142-155). Society for Industrial and Applied Mathematics.
@inproceedings{meyer2021, title={Hutch++: Optimal stochastic trace estimation}, author={Meyer, Raphael A and Musco, Cameron and Musco, Christopher and Woodruff, David P}, booktitle={Symposium on Simplicity in Algorithms (SOSA)}, pages={142--155}, year={2021}, organization={SIAM} }
vbald
vbald(matvec, shape=None, upper=None, moments=5, samples=5, mc_samples=64, method='rademacher', **backend)
Variational Bayesian Approximation of Log Determinants
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matvec |
`sparse tensor or callable(tensor) -> tensor`
|
Function that computes the matrix-vector product |
required |
shape |
`sequence[int]`
|
"vector" shape |
None
|
upper |
`float`
|
Upper bound on eigenvalues |
None
|
moments |
`int`
|
Number of moments |
1
|
samples |
`int`
|
Number of samples for moment estimation |
5
|
mc_samples |
`int`
|
Number of samples for Monte Carlo integration |
64
|
method |
`{'rademacher', 'gaussian'}`
|
Sampling method |
'rademacher'
|
Returns:
| Name | Type | Description |
|---|---|---|
logdet |
`scalar tensor`
|
|
Reference
- Granziol, D., Wagstaff, E., Ru, B.X., Osborne, M. and Roberts, S., 2018.
VBALD-Variational Bayesian approximation of log determinants.
arXiv preprint.
@article{granziol2018, title={VBALD-Variational Bayesian approximation of log determinants}, author={Granziol, Diego and Wagstaff, Edward and Ru, Bin Xin and Osborne, Michael and Roberts, Stephen}, journal={arXiv preprint arXiv:1802.08054}, year={2018} }
maxeig_power
Estimate the maximum eigenvalue of a matrix by power iteration
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matvec |
`sparse tensor or callable(tensor) -> tensor`
|
Function that computes the matrix-vector product |
required |
shape |
`sequence[int]`
|
"vector" shape |
None
|
max_iter |
`int`
|
|
512
|
tol |
`float`
|
|
1e-6
|
Returns:
| Name | Type | Description |
|---|---|---|
maxeig |
`scalar tensor`
|
Largest eigenvalue |