Skip to content

Instantly share code, notes, and snippets.

@Hanrui-Wang
Created September 23, 2019 20:48
Show Gist options
  • Save Hanrui-Wang/30ea2a1bf38ed06c0f263c68c67a0115 to your computer and use it in GitHub Desktop.
Save Hanrui-Wang/30ea2a1bf38ed06c0f263c68c67a0115 to your computer and use it in GitHub Desktop.
get_nonzero_index in pytorch
mask_i = (target >= start) & (target < end)
indices_i = mask_i.nonzero().squeeze()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment