Ok, I figured some things out by experimentation.
Suppose V is a matrix (it happens to be 5 different timeseries):
V = torch.arange(50).reshape((5,10))
tensor([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
[20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
[30, 31, 32, 33, 34, 35, 36, 37, 38, 39],
[40, 41, 42, 43, 44, 45, 46, 47, 48, 49]])
We construct a matrix of indexes, as in TomB’s response above. These represent lookbacks (A) starting at each available timepoint:
A = torch.LongTensor([0,1,3])
M = lb+(torch.arange(7, dtype=torch.long)[None,:].t())
tensor([[0, 1, 3],
[1, 2, 4],
[2, 3, 5],
[3, 4, 6],
[4, 5, 7],
[5, 6, 8],
[6, 7, 9]]
Then the derived lookback timeseries for each of the 5 original series are:
V[:,M]
tensor([[[ 0, 1, 3],
[ 1, 2, 4],
[ 2, 3, 5],
[ 3, 4, 6],
[ 4, 5, 7],
[ 5, 6, 8],
[ 6, 7, 9]],
[[10, 11, 13],
[11, 12, 14],
[12, 13, 15],
[13, 14, 16],
[14, 15, 17],
[15, 16, 18],
[16, 17, 19]],
[[20, 21, 23],
[21, 22, 24],
[22, 23, 25],
[23, 24, 26],
[24, 25, 27],
[25, 26, 28],
[26, 27, 29]],
[[30, 31, 33],
[31, 32, 34],
[32, 33, 35],
[33, 34, 36],
[34, 35, 37],
[35, 36, 38],
[36, 37, 39]],
[[40, 41, 43],
[41, 42, 44],
[42, 43, 45],
[43, 44, 46],
[44, 45, 47],
[45, 46, 48],
[46, 47, 49]]])
I realize this usage may be obscure, but maybe it will help someone someday. I am gratified that PyTorch is esthetic and consistent!