How to expand a variable on given dimension?

For example , I want to expand a variable with 2150 to 2 * 4 50
, which should equal to stack(variable
4,dim=1)

Use variable.expand (2,4,50) to get something similar as with torch.cat in your example. If you really meant stack, throw in .unsqueeze and amend the dimensions in expand.
With the broadcasting functionality in master / the next release, you often don’t need to use expand.

Best regards

Thomas

Thank you

I tried expand() but the module says assert_error in hx.contiguous().

How should I fix that?

var = var.contiguous()

1 Like