No broadcasting for Variable?

Hi, its my second day with PyTorch. I have ran into this problem:
a = Variable(torch.randn(5, 3))
b = Variable(torch.randn(3))
print(a/b)

It is throwing an error:
RuntimeError: inconsistent tensor size at /data/users/soumith/builder/wheel/pytorch-src/torch/lib/TH/generic/THTensorMath.c:869

What should I do now? In numpy, I would have done so through broadcasting:
x = np.random.randn(5,3)
y = np.random.randn(3)
print(x/y)

you can use expand_as as below:
a / b.expand_as(a)

3 Likes

Thanks for the suggestion. Also, what is the reason that broadcasting is not supported?

You can see this post Broadcasting? Or alternative solutions