AttributeError: module 'torch' has no attribute 'hstack'

Viewed 5245

I am following this doc for hstack.

a = torch.tensor([1, 2, 3])
b = torch.tensor([4, 5, 6])
torch.hstack((a,b))

But I keep getting the error:

AttributeError: module 'torch' has no attribute 'hstack'

Here is the torch version that results in this error:

torch.__version__
'1.6.0+cpu'

What am I doing wrong?

1 Answers

Apparently you are calling a function that does not exist YET in your PyTorch version --this is what the error message is about.

Your link points to the help page related to developers preview: note .8.0a0+342069f version number in the top left corner. When clicking, Click here to view docs for latest stable release. link - an error message come.

This function becomes available in torch version 1.8.0. --until then consider using torch.cat with `dim=1'.

torch.cat([a,b], dim=1)  # a, b - 2d torch.Tensors
Related