Idea

Mean Example

import torch

t = torch.FloatTensor([[1, 2], [3, 4]])
print(t)

print(t.mean()) # 전체 평균
print(t.mean(dim=0)) # 행을 1로!
print(t.mean(dim=1)) # 열을 1로!

Untitled

Sum Example

import torch

t = torch.FloatTensor([[1, 2], [3, 4]])
print(t)

print(t.sum()) # 전체 합
print(t.sum(dim=0)) # 행을 1로!
print(t.sum(dim=1)) # 열을 1로!

Untitled

Max and Argmax Example

import torch

t = torch.FloatTensor([[1, 2], [3, 4]])
print(t)

print(t.max()) # Returns one value : max

print(t.max(dim=0)) # Returns two values : max and argmax
print('Max : ', t.max(dim=0)[0])
print('Argmax : ', t.max(dim=0)[1])

print(t.max(dim=1))
print(t.max(dim=-1))

Untitled