-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Labels
Description
The following snippet demonstrates the problem:
import torch
import torch.nn
from torch.autograd import Variable
import numpy as np
x = Variable(torch.from_numpy(np.random.randn(4, 6, 5)).float(), requires_grad=True)
x = torch.transpose(x, 1, 2)
conv = torch.nn.Conv1d(in_channels=5, out_channels=10, kernel_size=2)
result = torch.sum(conv(x))
result.backward()Running this code and you will get the following error:
File ".../lib/python3.5/site-packages/torch/tensor.py", line 214, in view
raise ValueError("input should be contiguous")
ValueError: input should be contiguous
The fix is to change here to output += [t.contiguous().view(*size)]