Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

torch.return_types.max as Tensor

Tags:

python

pytorch

I try to pass torch.max() return type (torch.return_types.max) as argument to function torch.tile():

torch.tile(torch.max(x), (1, 1, 1, 5))

The error is: TypeError: tile(): argument 'input' (position 1) must be Tensor, not torch.return_types.max.

How can I convert torch.return_types.max to Tensor? Maybe I should use another function to find maximum in Tensor?

like image 561
evaleria Avatar asked Nov 16 '25 08:11

evaleria


1 Answers

For this error to be true, you have to be using some dim=?, because only then torch.max will return a tuple of (values, indices).

You can fix that error by using only the first output:

torch.tile(torch.max(x, dim=0)[0], (1, 1, 1, 5))
like image 151
Berriel Avatar answered Nov 17 '25 22:11

Berriel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!