Skip to content
Advertisement

Convert a list of tensors to tensors of tensors pytorch

I have this code:

JavaScript

I am getting the error:

ValueError: only one element tensors can be converted to Python scalars

How can I convert the list of tensors to a tensor of tensors in pytorch?

Advertisement

Answer

Here is a solution:

JavaScript
Advertisement