Hi, I was implementing a Time-Delay Neural Network as a warmup to using PyTorch and have gotten it to work on a CPU but the same model won’t work on the GPU because one of the variables that I have is not a .cuda type variable.
class TDNN(nn.Module):
    def __init__(......):
        self.context = Variable(torch.LongTensor(context))
        self.kernel = nn.Parameter(torch.Tensor(output_dim, input_dim, self.kernel_width).normal_(0,stdv))
        self.bias = nn.Parameter(torch.Tensor(output_dim).normal_(0,stdv))

In the above snippet, I’m pretty sure that after calling net = TDNN().cuda() the kernel and bias are now .cuda type tensors but context is not. I tried including the context as a parameter but then when I initialize my optimizer like: optimizer = optim.Adam(net.parameters()) it gives me an error since I don’t want the gradient to be computed for the context variable.
To give some more details: the context tensor is being used in a torch.index_select call. This is why I have it initialized as a LongTensor.
I could probably figure out a hack to solve this but I was wondering what the best practice was for a problem like this.
Thanks!