Search code examples
pytorchf#tensordiffsharp

DiffSharp sliding window implementation example


According to this issue Check view operations correspond to torch #199 It seems like it is not hard to implement sliding window function with DiffSharp Tensor. However I cannot get a hint searching DiffSharp official website.

In PyTorch, the unfold is like:

x = torch.arange(1., 20)
x.unfold(0,4,2)

tensor([[ 1.,  2.,  3.,  4.],  
        [ 3.,  4.,  5.,  6.],  
        [ 5.,  6.,  7.,  8.],  
        [ 7.,  8.,  9., 10.],  
        [ 9., 10., 11., 12.],  
        [11., 12., 13., 14.],  
        [13., 14., 15., 16.],  
        [15., 16., 17., 18.]])

How do I correctly implement unfold operator with DiffSharp Tensor?


Solution

  • Using unfold provided by TensorSharp instead works fine. Implement miscellaneous utility functions