Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

TBPTTIter.split_length() error #75

Open
hash2430 opened this issue Apr 9, 2019 · 1 comment
Open

TBPTTIter.split_length() error #75

hash2430 opened this issue Apr 9, 2019 · 1 comment

Comments

@hash2430
Copy link

hash2430 commented Apr 9, 2019

TBPTTIter.split_length() gives following error
"TypeError: mul(): argument 'other' (position 1) must be Tensor, not list"
while trying
"seq = [self.seq_len] * (seq_size / self.seq_len)"
It only makes sense to me that line raises that error.
Does that line work well for others?

I mean, that could have been caused by pytorch version mismatch but it's hard to believe that line works well for other versions of pytorch.

I'm confused if I should work on setting the right environment or fix that function to solve that error.

@arora-akshay
Copy link

Use below code. It will solve this problem

sqs = seq_size.clone().detach()

    seq = [self.seq_len] * (sqs.item() / self.seq_len)
    if sqs.item() % self.seq_len != 0:
        seq += [sqs.item() % self.seq_len]
    seq += [0] * (batch_seq_len - len(seq))
    return torch.LongTensor(seq)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants