# AttributeError: module 'torch' has no attribute 'maximum'

**URL:** <https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756>\
**Category:** Uncategorized\
**Created:** [September 29, 2020, 7:13pm UTC](https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756 "2020-09-29T19:13:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ziyu\_Chen](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ziyu_chen/32/14158_2.png) [@Ziyu\_Chen](https://discuss.pytorch.org/u/Ziyu_Chen)\
**Post date:** [September 29, 2020, 7:13pm UTC](https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756/1 "2020-09-29T19:13:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [September 29, 2020, 7:15pm UTC](https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756/2 "2020-09-29T19:15:54Z")

</div>

I think it is `torch.max(x, y)`. Not that it’s going to be terribly interesting for your tensors…

Best regards

Thomas

---

<div class="post-metadata">

**Author:** ![Ziyu\_Chen](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ziyu_chen/32/14158_2.png) [@Ziyu\_Chen](https://discuss.pytorch.org/u/Ziyu_Chen)\
**Post date:** [September 29, 2020, 7:24pm UTC](https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756/3 "2020-09-29T19:24:05Z")

</div>

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](https://pytorch.org/docs/master/generated/torch.maximum.html#torch.maximum)

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [September 29, 2020, 8:18pm UTC](https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756/4 "2020-09-29T20:18:17Z")

</div>

They were added to the dev branch just a month ago ([Aug 26](https://github.com/pytorch/pytorch/pull/42579)) and you are using the dev branch documentation.

---

<div class="post-metadata">

**Author:** ![Ziyu\_Chen](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ziyu_chen/32/14158_2.png) [@Ziyu\_Chen](https://discuss.pytorch.org/u/Ziyu_Chen)\
**Post date:** [September 29, 2020, 8:51pm UTC](https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756/5 "2020-09-29T20:51:38Z")

</div>

I see, thank you very much!

---

<div class="post-metadata">

**Author:** ![ashish\_singh](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ashish_singh/32/33776_2.png) [@ashish\_singh](https://discuss.pytorch.org/u/ashish_singh)\
**Post date:** [October 20, 2021, 10:31am UTC](https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756/6 "2021-10-20T10:31:44Z")

</div>

hi  
I am getting error torch has no ‘minimum’ attribute  
i am doing bigbird model project in pytorch

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [October 20, 2021, 8:34pm UTC](https://discuss.pytorch.org/t/attributeerror-module-torch-has-no-attribute-maximum/97756/7 "2021-10-20T20:34:26Z")

</div>

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.
