pytorch-dnc icon indicating copy to clipboard operation
pytorch-dnc copied to clipboard

batch_first argument doesn’t work

Open Trungmaster5 opened this issue 5 years ago • 1 comments

Hi, I just want to let you know that with current implementation (file dnc.py, line 76:86), the batch_first will always be True. It is trivial but sometime troublesome. Have a nice day.

Trungmaster5 avatar Mar 13 '20 05:03 Trungmaster5

I think you might be right, when I set batch_first = True and I give input of shape bs x ts x n. I get this error with batch size (bs): 256 File "/home/root/pytorch/lib/python3.5/site-packages/dnc/dnc.py", line 223, in forward inputs = [T.cat([input[:, x, :], last_read], 1) for x in range(max_length)] File "/home/root/pytorch/lib/python3.5/site-packages/dnc/dnc.py", line 223, in <listcomp> inputs = [T.cat([input[:, x, :], last_read], 1) for x in range(max_length)] RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 256 and 1 in dimension 0 at /pytorch/aten/src/THC/generic/THCTensorMath.cu:71 But when I permute my input to shape ts x bs x n and set batch_first = False, I do not get the error.

srikanthmalla avatar Mar 14 '20 04:03 srikanthmalla