torch.min、torch.max、torch.argmax

t o r c h . m i n 、 t o r c h . m a x 、 t o r c h . a r g m a x torch.min、torch.max、torch.argmax torch.mintorch.maxtorch.argmax

torch.max() and torch.min() are functions to compare the size of tensor

x = torch.rand(1,3)
print(x)
print(torch.min(x))
 
y = torch.rand(2,3)
print(y)
print(torch.min(y))

Insert picture description here

Specify the comparison dimension: torch.max(input,dim)

y = torch.rand(5,3)
print("***********")
print(y)
print("***********")
print(torch.max(y,0))

Insert picture description here

y = torch.rand(5,6)
print("***********")
print(y)
print("***********")
print(torch.max(y,1))

Insert picture description here

Comparison of two tensors: not necessarily the same size structure

If it is not the same size structure, it must be broadcastable

x = torch.rand(2,3)
y = torch.rand(2,3)
print("***********")
print(x)
print("***********")
print(y)
print("*****比较结果******")
print(torch.max(x,y))

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41375318/article/details/114629760