python - Changing a list of tensors to a tensor of lists ...
datascience.stackexchange.com › questions › 92946Apr 12, 2021 · and this list becomes like this [<tf.Tensor: shape=(), dtype=string, numpy=b'I have gone and you will go'>, <tf.Tensor: shape=(), dtype=string, numpy=b'we will go'>] But I want to have an object like this <tf.Tensor: shape=(3,), dtype=string, numpy=array([b'I have gone and you will go', b'we will go'], dtype=object)>
python - converting list of tensors to tensors pytorch ...
stackoverflow.com › questions › 55050717Mar 08, 2019 · import torch a = torch.arange (8).reshape (2, 2, 2) b = torch.arange (12).reshape (2, 2, 3) my_list = [a, b] my_tensor = torch.cat ( [a, b], dim=2) print (my_tensor.shape) #torch.Size ( [2, 2, 5]) you haven't explained your goal so another option is to use pad_sequence like this: