Is there a tensor.item() equivalent for a tensor containing a list in pytorch?
In pytorch, if I define a one-element tensor as follows:

&gt;&gt;&gt; import torch
&gt;&gt;&gt; target1 = torch.tensor([5])


I'm able to pull out the value of its one element like this:

&gt;&gt;&gt; target1.item()
5


What I would like to know is if when my tensor is defined as:

target2 = torch.tensor([[5], [5], [5], [5]])


Is there some way (similar or not to .item() above) to pull out all of its entries into a list like:

&gt;&gt;&gt; target2.(something)
[5, 5, 5, 5]


I can't seem to find any function in the documentation that supports an operation like this.

You can use 

target2.numpy().ravel() or 

target2.view(-1).numpy() or

target2.view(target2.numel()).numpy()

Out[1]: array([5, 5, 5, 5], dtype=int64)

