Search notes:

torch: multiplication

>>> a = torch.tensor([ 2, 4, 3 ])
>>> a * 3
tensor([ 6, 12,  9])

>>> b = torch.tensor([ 5, 7, 2 ])
>>> torch.mul(a, b)
tensor([10, 28,  6])

>>> a * b
tensor([10, 28,  6])
>>> a = torch.tensor([[ 1, 2, 3, 4 ]])
>>> a
tensor([[1, 2, 3, 4]])

>>> b = torch.tensor([ [40], [30], [20], [10] ])
>>> b
tensor([[40],
        [30],
        [20],
        [10]])

>>> a*b
tensor([[ 40,  80, 120, 160],
        [ 30,  60,  90, 120],
        [ 20,  40,  60,  80],
        [ 10,  20,  30,  40]])

mm

import torch

m1 = torch.tensor([

  [ 0.9  ,  1.3 ],
  [ 4.2  ,  5.2 ],
  [ 2.1  ,  3.0 ]
 
])


m2 = torch.tensor([

  [ 0.1  ,  2.8  ,  3.1  ,  1.8  ,  2.6 ],
  [ 4.8  ,  3.0  ,  0.2  ,  2.5  ,  3.8 ]

])

r = m1.mm(m2)       ; print(r)
r = torch.mm(m1, m2); print(r) # same thing

print(r)
Multiplying a 3x2 matrix with a 2x5 matrix produces a 3x5 matrix, the ouptut of print(r) is:
tensor([[ 6.3300,  6.4200,  3.0500,  4.8700,  7.2800],
        [25.3800, 27.3600, 14.0600, 20.5600, 30.6800],
        [14.6100, 14.8800,  7.1100, 11.2800, 16.8600]])

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201636, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/libraries/torch/members/multiplication/index(88): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78