Issue
I have a tenor.long
scalar named x. how can I make a list of tensor tensor[(x.detached().numpy())]
without converting x to numpy
Solution
If I understand correctly, you want to add another dimension (by converting to a list
, you'd have an iterable container/wrapper like a dimensional tensor; unless you want any list
-specific operations, most of the time you want to stick to a tensor
object for further processing).
To add a dim (making the tensor 1-D), you can use unsqueeze
:
x.unsqueeze(dim=0)
view
/reshape
/index-ing can be used as well:
x.view(-1)
x.reshape(-1)
x[None]
Answered By - heemayl
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.