I use PyTorch version 0.2.0_4 and get an IndexError which I cannot explain:
X: torch.Size([25, 8])
TYPE: <class 'list'>
IndexError: When performing advanced indexing the indexing objects must be LongTensors or convertible to LongTensors
I cannot understand why this happens and I have no idea how to fix this. Any help appreciated.
can you do:
print(self.neuron_map[k]), I’m curious of it’s contents.
INDS: [0, 1]
inds = torch.LongTensor(self.neuron_map[k])
RuntimeError: tried to construct a tensor from a int sequence, but found an item of type numpy.int64 at index (0)
I actually found a workaround:
inds = np.array(self.neuron_map[k], dtype=np.int64)
inds = torch.LongTensor(inds)
I actually have an additional question. The reason, I am splitting the tensor is to apply linear units (like in last posted code line). For the result, i use:
x_out = torch.cat(nn_list, 1)
How efficient is this, as compared to manually implement an autograd.Function (forward and backward)?
it should be pretty efficient if
x[:, inds] is large enough. the matrix multiply will prob dominate the cost.
Writing a batched matrix multiply by hand is not easy to do efficiently.