Open Anusha851 opened 3 years ago
You can add a new axis by using None
as selector for your tensor/array.
Like this you can "prepend" an extra dimension to 2-D data in numpy and torch:
# datapoints have shape [4, 768]
datapoints = datapoints[None, :, :]
# datapoints now have shape [1, 4, 768]
By swapping None
with :
, you could also reshape to [4, 1, 768] or [4, 768, 1].
If you need to swap 4 and 768 for whatever reason, have a look at .transpose()
Source: https://sparrow.dev/adding-a-dimension-to-a-tensor-in-pytorch/
Thank you.
I get the following error for Bayesian GRU implementation.
ValueError Traceback (most recent call last)