April 5, 2024, 10:40 p.m. | Super Kai (Kazuya Ito)

DEV Community dev.to

*My post explains min(), max(), argmin() and argmax().


sum() can get the sum values as shown below:


*Memos:




  • sum() can be called both from torch and a tensor.

  • The 2nd argument is one or more dimensions with torch.

  • The 1st argument is one or more dimensions with a tensor.



import torch

my_tensor = torch.tensor([[5, 4, 7, 7],
[6, 5, 3, 5],
[3, 8, 9, 3]])
torch.sum(my_tensor)
my_tensor.sum()
# tensor(65)

torch.sum(my_tensor, 0)
my_tensor.sum(0)
torch.sum(my_tensor, (0,))
my_tensor.sum((0,))
torch.sum(my_tensor, …

dimensions functional import max mean memos pytorch sum tensor torch values

Software Engineer for AI Training Data (School Specific)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Python)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Tier 2)

@ G2i Inc | Remote

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US