Home > Enterprise >  Why do I get the error: ZeroDivisionError: 0.0 cannot be raised to a negative power error when loadi
Why do I get the error: ZeroDivisionError: 0.0 cannot be raised to a negative power error when loadi

Time:04-20

I am trying to make inference on the DeiT small variant from timm.

from timm.models import create_model
model = create_model('deit_small_patch16_224', pretrained=True)

But I get the error:

self.scale = head_dim ** -0.5
ZeroDivisionError: 0.0 cannot be raised to a negative power.

However, creating a different model with model = create_model('deit_tiny_patch16_224', pretrained=True), I can make inference successfully and it works pretty fine. I understand this error is as a result of a zero being divided by a non-zero value or when being raised to the power of non-zero. But I don't quite get why this model is flagging an error from timm even before loading any data.

CodePudding user response:

It was an error with my version of timm. Upgrading timm: pip install --upgrade timm solved the problem.

  • Related