tfp.substrates.numpy.math.gram_schmidt
Stay organized with collections
Save and categorize content based on your preferences.
Implementation of the modified Gram-Schmidt orthonormalization algorithm.
tfp.substrates.numpy.math.gram_schmidt(
vectors, num_vectors=None
)
We assume here that the vectors are linearly independent. Zero vectors will be
left unchanged, but will also consume an iteration against num_vectors
.
From [1]: "MGS is numerically equivalent to Householder QR factorization
applied to the matrix A augmented with a square matrix of zero elements on
top."
Historical note, see [1]: "modified" Gram-Schmidt was derived by Laplace [2],
for elimination and not as an orthogonalization algorithm. "Classical"
Gram-Schmidt actually came later [2]. Classical Gram-Schmidt has a sometimes
catastrophic loss of orthogonality for badly conditioned matrices, which is
discussed further in [1].
References
[1] Bjorck, A. (1994). Numerics of gram-schmidt orthogonalization. Linear
Algebra and Its Applications, 197, 297-316.
[2] P. S. Laplace, Thiorie Analytique des Probabilites. Premier Supple'ment,
Mme. Courtier, Paris, 1816.
[3] E. Schmidt, über die Auflosung linearer Gleichungen mit unendlich vielen
Unbekannten, Rend. Circ. Mat. Pulermo (1) 25:53-77 (1908).
Args |
vectors
|
A Tensor of shape [..., d, n] of d -dim column vectors to
orthonormalize.
|
num_vectors
|
Optional, number of leading vectors of the result to make
orthogonal. If unspecified, then num_vectors = n , implying that each
vector except for the last will be used in sequence.
|
Returns |
A Tensor of shape [..., d, n] corresponding to the orthonormalization.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.substrates.numpy.math.gram_schmidt\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/substrates/numpy/math/gram_schmidt.py#L28-L85) |\n\nImplementation of the modified Gram-Schmidt orthonormalization algorithm.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tfp.experimental.substrates.numpy.math.gram_schmidt`](https://www.tensorflow.org/probability/api_docs/python/tfp/substrates/numpy/math/gram_schmidt)\n\n\u003cbr /\u003e\n\n tfp.substrates.numpy.math.gram_schmidt(\n vectors, num_vectors=None\n )\n\nWe assume here that the vectors are linearly independent. Zero vectors will be\nleft unchanged, but will also consume an iteration against `num_vectors`.\n\nFrom \\[1\\]: \"MGS is numerically equivalent to Householder QR factorization\napplied to the matrix A augmented with a square matrix of zero elements on\ntop.\"\n\nHistorical note, see \\[1\\]: \"modified\" Gram-Schmidt was derived by Laplace \\[2\\],\nfor elimination and not as an orthogonalization algorithm. \"Classical\"\nGram-Schmidt actually came later \\[2\\]. Classical Gram-Schmidt has a sometimes\ncatastrophic loss of orthogonality for badly conditioned matrices, which is\ndiscussed further in \\[1\\].\n\n#### References\n\n\\[1\\] Bjorck, A. (1994). Numerics of gram-schmidt orthogonalization. Linear\nAlgebra and Its Applications, 197, 297-316.\n\n\\[2\\] P. S. Laplace, Thiorie Analytique des Probabilites. Premier Supple'ment,\nMme. Courtier, Paris, 1816.\n\n\\[3\\] E. Schmidt, über die Auflosung linearer Gleichungen mit unendlich vielen\nUnbekannten, Rend. Circ. Mat. Pulermo (1) 25:53-77 (1908).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `vectors` | A Tensor of shape `[..., d, n]` of `d`-dim column vectors to orthonormalize. |\n| `num_vectors` | Optional, number of leading vectors of the result to make orthogonal. If unspecified, then `num_vectors = n`, implying that each vector except for the last will be used in sequence. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A Tensor of shape `[..., d, n]` corresponding to the orthonormalization. ||\n\n\u003cbr /\u003e"]]