Inyoung Kim 김인영
Inyoung Kim 김인영

Reputation: 1586

Slicing a tensor with tensor

I want to make a tensor of moving window. I'm using a list comprehension, but, this is sequential making it extremely slow.

weight_list = [w[:, :, :, i : i + self.l_c] for i in range(n)]

I want to find

weight = torch.for_example.index_slice(w, start_indices=n, slice_length=self.l_c, dim=-1)

I've seen methods of "indexing". But not slicing. Is there a method for this?

Upvotes: 1

Views: 156

Answers (1)

Shai
Shai

Reputation: 114786

It seems like you are looking for unfolding of w with kernel size (1, self.l_c).

Upvotes: 1

Related Questions