Update eva.py (#2058)

* Update eva.py

When argument class token = False, self.cls_token = None.

Prevents error from attempting trunc_normal_ on None:
AttributeError: 'NoneType' object has no attribute 'uniform_'

* Update eva.py

fix
pull/1974/merge
LR 2023-12-17 00:10:45 +01:00 committed by GitHub
parent 7da34a999a
commit e0079c92da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -479,7 +479,8 @@ class Eva(nn.Module):
self.apply(self._init_weights)
if self.pos_embed is not None:
trunc_normal_(self.pos_embed, std=.02)
trunc_normal_(self.cls_token, std=.02)
if self.cls_token is not None:
trunc_normal_(self.cls_token, std=.02)
self.fix_init_weight()
if isinstance(self.head, nn.Linear):