Skip to content

Commit

Permalink
Updated linalg functions in tensors_deeper_tutorial.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ignaciobartol committed Jun 28, 2024
1 parent 2b0e464 commit a312891
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 a312891

Please sign in to comment.