I ran a simple code on my macOS with torch version = 1.6.0 and python version = 3.7.4:
import torch
x = torch.tensor([[1],[2],[3],[5]],dtype = torch.float)
y = torch.tensor([[1],[2],[3],[4]],dtype = torch.float)
print(torch.maximum(x,y))
But I got AttributeError: module ‘torch’ has no attribute ‘maximum’.
Torch does have maximum function which returns the elementwise maximum of two tensors. Where did I get wrong? I’ve been stuck on this for quite a while. Thanks.
I think it is torch.max(x, y)
. Not that it’s going to be terribly interesting for your tensors…
Best regards
Thomas
Hi tom, yes, torch.max can give the right output and it can also give the maximum value of all the elements of a tensor. But I was wondering why torch.maximum would not work, since it’s pretty clear this function is designed for it as in https://pytorch.org/docs/master/generated/torch.maximum.html#torch.maximum
They were added to the dev branch just a month ago (Aug 26) and you are using the dev branch documentation.
I see, thank you very much!
hi
I am getting error torch has no ‘minimum’ attribute
i am doing bigbird model project in pytorch
You might need to update PyTorch to be able to use this method.
@tom mentioned the PR where the minimum
and `maximum methods were merged and since it’s ~1 year old, I assume you are also using an older PyTorch release.