my pytorch model outputs actions in the form of a tensor [x1, x2, x3, ... x10] which represents the sequence of actions taken that alter the current environment. I would like to change that tensor into a sequence of states that have empty states initialized with a fill value, which I'll denote f.
So, my goal is to convert
O_1 = [x1, x2, x3, x4, x5, x6, x7, x8, x9, x10]
into
O_2 = [
[x1, f, f, f, f, f, f, f, f, f],
[x1, x2, f, f, f, f, f, f, f, f],
[x1, x2, x3, f, f, f, f, f, f, f],
[x1, x2, x3, x4, f, f, f, f, f, f],
[x1, x2, x3, x4, x5, f, f, f, f, f],
[x1, x2, x3, x4, x5, x6, f, f, f, f],
[x1, x2, x3, x4, x5, x6, x7, f, f, f],
[x1, x2, x3, x4, x5, x6, x7, x8, f, f],
[x1, x2, x3, x4, x5, x6, x7, x8, x9, f],
[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10]
]
I could write a function to do this manually but I was wondering if there is a easier pytorch-y way (like with certain tensor transformations) to do this conversion. Moreover, is there a way to do this that preserves the computational graph from O_1 to O_2?