Home > Back-end >  Resizing a vector by interpolation
Resizing a vector by interpolation

Time:10-03

I want to resize a vector by interpolating.

Torch happen to have a function to do that, but it does not work for 1D vectors !! Interpolate

 In [25]: torch.nn.functional.interpolate(torch.randn(5),10)


 NotImplementedError: Input Error: Only 3D, 4D and 5D input Tensors supported (got 1D) for the modes: nearest | linear | bilinear | bicubic | trilinear | area | nearest-exact (got nearest)

Any idea how to do that ?

CodePudding user response:

I am not sure what kind of vector you are talking about since you did not provide much info. However, I think you should check out scipy's interpolate package

CodePudding user response:

Maybe extend it to 3D using np.expand_dims, and the reduce it back to 1D with [0][0].

  • Related