Skip to content

Instantly share code, notes, and snippets.

@Blaizzy
Created May 5, 2020 17:17
Show Gist options
  • Select an option

  • Save Blaizzy/378c3fc1a67b4ccb973b46e06db121d3 to your computer and use it in GitHub Desktop.

Select an option

Save Blaizzy/378c3fc1a67b4ccb973b46e06db121d3 to your computer and use it in GitHub Desktop.
class SavedFeatures():
def __init__(self, m): self.hook = m.register_forward_hook(self.hook_fn)
def hook_fn(self, model, input, output): self.features = output
def remove(self): self.hook.remove()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment