huggingface / pytorch-image-models

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNet-V3/V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more

Home Page:https://huggingface.co/docs/timm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] AttributeError: module 'torch._C' has no attribute 'set_grad_enabled'

ahalev opened this issue · comments

File "/home/ahalev/miniconda3/envs/eye-image-env/lib/python3.8/site-packages/timm/loss/asymmetric_loss.py", line 40, in forward                                                                                                               
    torch._C.set_grad_enabled(False)                                                                                    
AttributeError: module 'torch._C' has no attribute 'set_grad_enabled'

New versions of torch deprecated torch._C.set_grad_enabled in favor of torch.set_grad_enabled, leading to an AttributeError here:

if self.disable_torch_grad_focal_loss:
torch._C.set_grad_enabled(False)