Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View roflmaostc's full-sized avatar
😕
Worried about climate change

Felix Wechsler roflmaostc

😕
Worried about climate change
View GitHub Profile
@roflmaostc
roflmaostc / interpolate3d.py
Created March 29, 2023 09:34 — forked from Kulbear/interpolate3d.py
Trilinear interpolation on a 3D regular grid, implemented with PyTorch.
import tensorflow as tf
import torch
import numpy as np
def gather_nd_torch(params, indices, batch_dim=1):
""" A PyTorch porting of tensorflow.gather_nd
This implementation can handle leading batch dimensions in params, see below for detailed explanation.
The majority of this implementation is from Michael Jungo @ https://stackoverflow.com/a/61810047/6670143
I just ported it compatible to leading batch dimension.