This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
napari.jl | |
Test using PyCall.jl to invoke Napari ( http://github.com/napari ) from | |
the Julia language ( https://julialang.org/ ) 1.3.1 | |
Mark Kittisopikul | |
January 29th, 2020 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |