That answer wouldn’t work for sequences with zeros or near-zeros in them (also really large numbers, but they’d render this whole thing a bit moot). I need a solution which won’t have numerical errors. That’s why I built the monstrosity up above.
In numpy, this is trivial. Is it not trivial in pytorch? Again, seems like I’ve missed some function.