m.bias.zero_()
m.weight.fill_(1.0)
- def forward(self, bs, with_readout=True):
+ def forward(self, bs, mode='standard'):
bs.x = F.pad(bs.x, (1, -1))
bs = self.embedding(bs)
- bs = self.trunk(bs)
- if with_readout:
+ if mode=='standard':
+ bs = self.trunk(bs)
bs = self.readout(bs)
+ elif mode=='head':
+ bs = self.trunk(bs)
+ elif mode=='deep':
+ r = []
+ for l in self.trunk:
+ bs = l(bs)
+ r += [ bs.slice() ]
+ bs = BracketedSequence(torch.cat(r, -1))
+ else:
+ raise ValueError
return bs