X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=mygpt.py;h=df6eab6076c713d4004fb9a412b4e92d31108c39;hb=c4eb660976808b873f32fe873819c4988aaf2ea5;hp=5ea4668203f0f4eaf9ccbc586f2d58a348fe0a3f;hpb=3602bfe2c4e1cd513759bf45cb83f8c2d914674b;p=beaver.git diff --git a/mygpt.py b/mygpt.py index 5ea4668..df6eab6 100755 --- a/mygpt.py +++ b/mygpt.py @@ -14,19 +14,6 @@ from torch.nn import functional as F ###################################################################### - -class WithResidual(nn.Module): - def __init__(self, *f): - super().__init__() - self.f = f[0] if len(f) == 1 else nn.Sequential(*f) - - def forward(self, bs): - bs.x = bs.x + self.f(bs).x - return bs - - -###################################################################### - # A BracketedSequence is a BxTx... tensor with a first and a nb time # steps to compute. @@ -57,6 +44,19 @@ class BracketedSequence: ###################################################################### +class WithResidual(nn.Module): + def __init__(self, *f): + super().__init__() + self.f = f[0] if len(f) == 1 else nn.Sequential(*f) + + def forward(self, bs): + bs.x = bs.x + self.f(bs).x + return bs + + +###################################################################### + + class CacheWrapper(nn.Module): def __init__(self, *f): super().__init__()