Skip to content

Instantly share code, notes, and snippets.

View korabelnikov's full-sized avatar

Korabelnikov Aleks korabelnikov

  • ARRIVAL
View GitHub Profile
@ProGamerGov
ProGamerGov / remove_hooks.py
Created May 1, 2022 18:23
Remove hooks in PyTorch without using the hook handle
from collections import OrderedDict
from typing import Callable, Dict, Optional
from warnings import warn
import torch
def _remove_all_forward_hooks(
module: torch.nn.Module, hook_fn_name: Optional[str] = None
) -> None:
"""