Skip to content

Commit

Permalink
Updated linalg functions in tensors_deeper_tutorial.py (#2959)
Browse files Browse the repository at this point in the history
Co-authored-by: Svetlana Karslioglu <[email protected]>
  • Loading branch information
ignaciobartol and svekars authored Aug 1, 2024
1 parent 740e3b0 commit 89b3343
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions beginner_source/introyt/tensors_deeper_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,17 +448,19 @@
m2 = torch.tensor([[3., 0.], [0., 3.]]) # three times identity matrix

print('\nVectors & Matrices:')
print(torch.cross(v2, v1)) # negative of z unit vector (v1 x v2 == -v2 x v1)
print(torch.linalg.cross(v2, v1)) # negative of z unit vector (v1 x v2 == -v2 x v1)
print(m1)
m3 = torch.matmul(m1, m2)
m3 = torch.linalg.matmul(m1, m2)
print(m3) # 3 times m1
print(torch.svd(m3)) # singular value decomposition
print(torch.linalg.svd(m3)) # singular value decomposition


##################################################################################
# This is a small sample of operations. For more details and the full inventory of
# math functions, have a look at the
# `documentation <https://pytorch.org/docs/stable/torch.html#math-operations>`__.
# For more details and the full inventory of linear algebra operations, have a
# look at this `documentation <https://pytorch.org/docs/stable/linalg.html>`__.
#
# Altering Tensors in Place
# ~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 89b3343

Please sign in to comment.