Skip to content
Advertisement

Tag: tensor

Convert 5D tensor to 4D tensor in PyTorch

In PyTorch I have a 5D tensor X of dimensions B x 9 x C x H x W. I want to convert it into a 4D tensor Y with dimensions B x 9C x H x W such that concatenation happens channel wise. To illustrate let, Then in the tensor Y, a to i should be channel wise concatenated.

How to get the last index of model’s prediction?

I am new to PyTorch. I have a variable pred which has a list of a tensor. So I wanted to access the last element which is the class. I did that by first converting the list into a tensor. Now, how do I access the last element or is there any better/efficient way of doing this? EDIT: For further

What does .view() do in PyTorch?

What does .view() do to a tensor x? What do negative values mean? Answer view() reshapes the tensor without copying memory, similar to numpy’s reshape(). Given a tensor a with 16 elements: To reshape this tensor to make it a 4 x 4 tensor, use: Now a will be a 4 x 4 tensor. Note that after the reshape the

Advertisement