evaleria
evaleria

Reputation: 1411

torch.return_types.max as Tensor

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?

Upvotes: 3

Views: 4435

Answers (1)

Berriel
Berriel

Reputation: 13661

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))

Upvotes: 4

Related Questions