Code seems to be working fine. Perhaps problem with your output_sliced
?
import numpy as np
import torch
batched_outputs = []
output_sliced = np.random.random((2,3))
batched_outputs.append(output_sliced)
batched_outputs = torch.from_numpy(np.asarray(batched_outputs))
I don't get any errors with the code above.
I don't know if you intended this, but do keep in mind that:
batched_outputs = []
output_sliced = np.random.random((2,3))
batched_outputs.append(output_sliced)
print(np.asarray(batched_outputs).shape)
gives you
(1, 2, 3)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…