Converting tensor into nested list

Hi. I can convert a nested list to a tensor like Nx.tensor([[1,2], [3,4]]). Is there any way to reverse this operation and convert the tensor back into the original nested list? Thanks.

2 Likes

I could be mistaken but I believe the simplest way is:

t = Nx.tensor([[1,2], [3,4]])

t
|> Nx.to_batched_list(1)
|> Enum.map(&Nx.to_flat_list/1)
3 Likes