Issue
I am trying to read multiple .gz file and return its content in one tensor as follows:
with ReadHelper('ark: gunzip -c /home/mnabih/kaldi/egs/timit/s5/exp/mono_ali/*.gz|') as reader:
for key, b in reader:
#print(type(b))
c = torch.from_numpy(b)
labels = torch.cat(c)
Unfortunately, it gives me this error:
cat(): argument 'tensors' (position 1) must be tuple of Tensors, not Tensor
Solution
As the error message explains, c
is a tensor. To use torch.cat()
you must pass a group of tensors or a list. To solve your problem you may use:
temp = list()
for key, b in reader:
temp.append(torch.from_numpy(b))
labels = torch.cat(temp)
For more, you can check the manual here
Answered By - André Pacheco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.