Skip to content

Commit

Permalink
update: add DecayParameter and NoDecayParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
typoverflow committed Sep 6, 2023
1 parent 30a6238 commit c2d8326
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion offlinerllib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

__version__ = "0.1.0"
__version__ = "0.1.1"
11 changes: 11 additions & 0 deletions offlinerllib/module/net/attention/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
from offlinerllib.module.net.attention.positional_encoding import BasePosEncoding


class DecayParameter(nn.Parameter):
pass

class NoDecayParameter(nn.Parameter):
pass


class BaseTransformer(nn.Module):
def __init__(self, *args, **kwargs):
super().__init__()
Expand Down Expand Up @@ -31,6 +38,10 @@ def configure_params(self):
no_decay.add(fpn)
elif pn.endswith("weight") and isinstance(m, whitelist_weight_modules):
decay.add(fpn)
elif isinstance(p, DecayParameter):
decay.add(fpn)
elif isinstance(p, NoDecayParameter):
no_decay.add(fpn)

# validate that we considered every parameter
param_dict = {pn: p for pn, p in self.named_parameters()}
Expand Down

0 comments on commit c2d8326

Please sign in to comment.