Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LayerNorm have a bias parameter attribute but is not instance of torch primitive modules #1229

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/super_gradients/training/utils/optimizer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def _get_no_decay_param_ids(module: nn.Module):
NOTE - ALL MODULES WITH ATTRIBUTES NAMED BIAS AND ARE INSTANCE OF nn.Parameter WILL BE CONSIDERED A BIAS PARAM FOR
ZERO WEIGHT DECAY.
"""
batchnorm_types = (_BatchNorm,)
norm_types = (_BatchNorm, nn.GroupNorm, nn.LayerNorm, nn.InstanceNorm1d, nn.InstanceNorm2d, nn.InstanceNorm3d)
torch_weight_with_bias_types = (_ConvNd, nn.Linear)
no_decay_ids = []
for name, m in module.named_modules():
if isinstance(m, batchnorm_types):
if isinstance(m, norm_types):
no_decay_ids.append(id(m.weight))
no_decay_ids.append(id(m.bias))
elif hasattr(m, "bias") and isinstance(m.bias, nn.Parameter):
Expand Down