Answers for "pytorch rolling window"

0

pytorch rolling window

import torch

x = torch.arange(10)#tensor([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9])
x.unfold(0,4,3) #Tensor.unfold(dimension, window_size, step) 

'''tensor([[0, 1, 2, 3],
        [3, 4, 5, 6],
        [6, 7, 8, 9]])'''
Posted by: Guest on September-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language