A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.pytorch.org/docs/stable/generated/torch.qr.html below:

torch.qr — PyTorch 2.8 documentation

Computes the QR decomposition of a matrix or a batch of matrices input, and returns a namedtuple (Q, R) of tensors such that input = Q R \text{input} = Q R input=QR with Q Q Q being an orthogonal matrix or batch of orthogonal matrices and R R R being an upper triangular matrix or batch of upper triangular matrices.

If some is True, then this function returns the thin (reduced) QR factorization. Otherwise, if some is False, this function returns the complete QR factorization.

Warning

torch.qr() is deprecated in favor of torch.linalg.qr() and will be removed in a future PyTorch release. The boolean parameter some has been replaced with a string parameter mode.

Q, R = torch.qr(A) should be replaced with

Q, R = torch.linalg.qr(A)

Q, R = torch.qr(A, some=False) should be replaced with

Q, R = torch.linalg.qr(A, mode="complete")

Warning

If you plan to backpropagate through QR, note that the current backward implementation is only well-defined when the first min ⁡ ( i n p u t . s i z e ( − 1 ) , i n p u t . s i z e ( − 2 ) ) \min(input.size(-1), input.size(-2)) min(input.size(1),input.size(2)) columns of input are linearly independent. This behavior will probably change once QR supports pivoting.

>>> a = torch.tensor([[12., -51, 4], [6, 167, -68], [-4, 24, -41]])
>>> q, r = torch.qr(a)
>>> q
tensor([[-0.8571,  0.3943,  0.3314],
        [-0.4286, -0.9029, -0.0343],
        [ 0.2857, -0.1714,  0.9429]])
>>> r
tensor([[ -14.0000,  -21.0000,   14.0000],
        [   0.0000, -175.0000,   70.0000],
        [   0.0000,    0.0000,  -35.0000]])
>>> torch.mm(q, r).round()
tensor([[  12.,  -51.,    4.],
        [   6.,  167.,  -68.],
        [  -4.,   24.,  -41.]])
>>> torch.mm(q.t(), q).round()
tensor([[ 1.,  0.,  0.],
        [ 0.,  1., -0.],
        [ 0., -0.,  1.]])
>>> a = torch.randn(3, 4, 5)
>>> q, r = torch.qr(a, some=False)
>>> torch.allclose(torch.matmul(q, r), a)
True
>>> torch.allclose(torch.matmul(q.mT, q), torch.eye(5))
True

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4