*Memos:
- My post explains min() and max().
- My post explains minimum() and maximum().
- My post explains fmin() and fmax().
- My post explains argmin() and argmax().
- My post explains kthvalue() and topk().
- My post explains cummin() and cummax().
aminmax() can get two of the 0D or more D tensors of zero or more minimum and maximum elements from the 0D or more D tensor of zero or more elements as shown below:
*Memos:
-
aminmax()
can be used with torch or a tensor. - The 1st argument(
input
) withtorch
or using a tensor(Required-Type:tensor
ofint
,float
orbool
). - There is
dim
argument withtorch
or a tensor(Optional-Type:int
): *Memos:- Setting
dim
can get zero or more 1st minimum and maximum elements. - You must use
dim=
.
- Setting
- There is
keepdim
argument withtorch
or a tensor(Optional-Default:False
-Type:bool
): *Memos:- You must use
keepdim=
. - My post explains
keepdim
argument.
- You must use
- There is
out
argument withtorch
(Optional-Default:None
-Type:tuple
(tensor
,tensor
) orlist
(tensor
,tensor
)): *Memos:-
out=
must be used. - My post explains
out
argument.
-
- The 0D tensor of one complex number with
dim=0
ordim=-1
works. - An empty 2D or more D
input
tensor or tensor doesn't work if not settingdim
. - An empty 1D
input
tensor or tensor doesn't work even if settingdim
.
import torch my_tensor = torch.tensor([[5, 4, 7, 7], [6, 5, 3, 5], [3, 8, 9, 3]]) torch.aminmax(input=my_tensor) my_tensor.aminmax() # torch.return_types.aminmax( # min=tensor(3), # max=tensor(9)) torch.aminmax(input=my_tensor, dim=0) torch.aminmax(input=my_tensor, dim=-2) # torch.return_types.aminmax( # min=tensor([3, 4, 3, 3]), # max=tensor([6, 8, 9, 7])) torch.aminmax(input=my_tensor, dim=1) torch.aminmax(input=my_tensor, dim=-1) # torch.return_types.aminmax( # min=tensor([4, 3, 3]), # max=tensor([7, 6, 9])) my_tensor = torch.tensor([[5., 4., 7., 7.], [6., 5., 3., 5.], [3., 8., 9., 3.]]) torch.aminmax(input=my_tensor) # torch.return_types.aminmax( # min=tensor(3.), # max=tensor(9.)) my_tensor = torch.tensor([[True, False, True, False], [False, True, False, True], [True, False, True, False]]) torch.aminmax(input=my_tensor) # torch.return_types.aminmax( # min=tensor(False), # max=tensor(True)) my_tensor = torch.tensor(5.+7.j) torch.aminmax(input=my_tensor, dim=0) torch.aminmax(input=my_tensor, dim=-1) # torch.return_types.aminmax( # min=tensor(5.+7.j), # max=tensor(5.+7.j)) my_tensor = torch.tensor([]) my_tensor = torch.tensor([[]]) my_tensor = torch.tensor([[[]]]) torch.aminmax(input=my_tensor) # Error my_tensor = torch.tensor([]) torch.aminmax(input=my_tensor, dim=0) # Error my_tensor = torch.tensor([[]]) torch.aminmax(input=my_tensor, dim=0) # torch.return_types.aminmax( # min=tensor([]), # max=tensor([])) my_tensor = torch.tensor([[[]]]) torch.aminmax(input=my_tensor, dim=0) # torch.return_types.aminmax( # min=tensor([], size=(1, 0)), # max=tensor([], size=(1, 0)))
amin() can get the 0D or more D tensor of zero or more minimum elements from the 0D or more D tensor of zero or more elements as shown below:
*Memos:
-
amin()
can be used withtorch
or a tensor. - The 1st argument(
input
) withtorch
or using a tensor(Required-Type:tensor
ofint
,float
orbool
). - The 2nd argument with
torch
or the 1st argument with a tensor isdim
(Optional-Type:int
,tuple
ofint
orlist
ofint
). *Settingdim
can get zero or more 1st minimum elements. - The 3rd argument with
torch
or the 2nd argument with a tensor iskeepdim
(Optional-Default:False
-Type:bool
). *My post explainskeepdim
argument. - There is
out
argument withtorch
(Optional-Default:None
-Type:tensor
): *Memos:-
out=
must be used. - My post explains
out
argument.
-
- An empty 2D or more D
input
tensor or tensor doesn't work if not settingdim
. - An empty 1D
input
tensor or tensor doesn't work even if settingdim
.
import torch my_tensor = torch.tensor([[5, 4, 7, 7], [6, 5, 3, 5], [3, 8, 9, 3]]) torch.amin(input=my_tensor) my_tensor.amin() torch.amin(input=my_tensor, dim=(0, 1)) torch.amin(input=my_tensor, dim=(0, -1)) torch.amin(input=my_tensor, dim=(1, 0)) torch.amin(input=my_tensor, dim=(1, -2)) torch.amin(input=my_tensor, dim=(-1, 0)) torch.amin(input=my_tensor, dim=(-1, -2)) torch.amin(input=my_tensor, dim=(-2, 1)) torch.amin(input=my_tensor, dim=(-2, -1)) # tensor(3) torch.amin(input=my_tensor, dim=0) torch.amin(input=my_tensor, dim=-2) torch.amin(input=my_tensor, dim=(0,)) torch.amin(input=my_tensor, dim=(-2,)) # tensor([3, 4, 3, 3]) torch.amin(input=my_tensor, dim=1) torch.amin(input=my_tensor, dim=-1) torch.amin(input=my_tensor, dim=(1,)) torch.amin(input=my_tensor, dim=(-1,)) # tensor([4, 3, 3]) my_tensor = torch.tensor([[5., 4., 7., 7.], [6., 5., 3., 5.], [3., 8., 9., 3.]]) torch.amin(input=my_tensor) # tensor(3.) my_tensor = torch.tensor([[True, False, True, False], [False, True, False, True], [True, False, True, False]]) torch.amin(input=my_tensor) # tensor(False) my_tensor = torch.tensor([]) my_tensor = torch.tensor([[]]) my_tensor = torch.tensor([[[]]]) torch.amin(input=my_tensor) # Error my_tensor = torch.tensor([]) torch.amin(input=my_tensor, dim=0) # Error my_tensor = torch.tensor([[]]) torch.amin(input=my_tensor, dim=0) # tensor([]) my_tensor = torch.tensor([[[]]]) torch.amin(input=my_tensor, dim=0) # tensor([], size=(1, 0))
amax() can get the 0D or more D tensor of zero or more maximum elements from the 0D or more D tensor of zero or more elements as shown below:
*Memos:
-
amax()
can be used withtorch
or a tensor. - The 1st argument(
input
) withtorch
or using a tensor(Required-Type:tensor
ofint
,float
orbool
). - The 2nd argument with
torch
or the 1st argument with a tensor isdim
(Optional-Type:int
,tuple
ofint
orlist
ofint
). *Settingdim
can get zero or more 1st maximum elements. - The 3rd argument with
torch
or the 2nd argument iskeepdim
(Optional-Default:False
-Type:bool
). *My post explainskeepdim
argument. - There is
out
argument withtorch
(Optional-Default:None
-Type:tensor
): *Memos:-
out=
must be used. - My post explains
out
argument.
-
- An empty 2D or more D
input
tensor or tensor doesn't work if not settingdim
. - An empty 1D
input
tensor or tensor doesn't work even if settingdim
.
import torch my_tensor = torch.tensor([[5, 4, 7, 7], [6, 5, 3, 5], [3, 8, 9, 3]]) torch.amax(input=my_tensor) my_tensor.amax() torch.amax(input=my_tensor, dim=(0, 1)) torch.amax(input=my_tensor, dim=(0, -1)) torch.amax(input=my_tensor, dim=(1, 0)) torch.amax(input=my_tensor, dim=(1, -2)) torch.amax(input=my_tensor, dim=(-1, 0)) torch.amax(input=my_tensor, dim=(-1, -2)) torch.amax(input=my_tensor, dim=(-2, 1)) torch.amax(input=my_tensor, dim=(-2, -1)) # tensor(9) torch.amax(input=my_tensor, dim=0) torch.amax(input=my_tensor, dim=-2) torch.amax(input=my_tensor, dim=(0,)) torch.amax(input=my_tensor, dim=(-2,)) # tensor([6, 8, 9, 7]) torch.amax(input=my_tensor, dim=1) torch.amax(input=my_tensor, dim=-1) torch.amax(input=my_tensor, dim=(1,)) torch.amax(input=my_tensor, dim=(-1,)) # tensor([7, 6, 9]) my_tensor = torch.tensor([[5., 4., 7., 7.], [6., 5., 3., 5.], [3., 8., 9., 3.]]) torch.amax(input=my_tensor) # tensor(9.) my_tensor = torch.tensor([[True, False, True, False], [False, True, False, True], [True, False, True, False]]) torch.amax(input=my_tensor) # tensor(True) my_tensor = torch.tensor([]) my_tensor = torch.tensor([[]]) my_tensor = torch.tensor([[[]]]) torch.amax(input=my_tensor) # Error my_tensor = torch.tensor([]) torch.amax(input=my_tensor, dim=0) # Error my_tensor = torch.tensor([[]]) torch.amax(input=my_tensor, dim=0) # tensor([]) my_tensor = torch.tensor([[[]]]) torch.amax(input=my_tensor, dim=0) # tensor([], size=(1, 0))
Top comments (0)