WIP examples

This commit is contained in:
thomwolf
2019-07-10 15:33:34 +02:00
parent ed6c8d37f4
commit 50b7e52a7f
5 changed files with 361 additions and 209 deletions

View File

@@ -393,7 +393,7 @@ class XLNetRelativeAttention(nn.Module):
x = x[1:, ...]
x = x.reshape(x_size[0], x_size[1] - 1, x_size[2], x_size[3])
# x = x[:, 0:klen, :, :]
x = torch.index_select(x, 1, torch.arange(klen))
x = torch.index_select(x, 1, torch.arange(klen, device=x.device, dtype=torch.long))
return x

View File

@@ -227,6 +227,8 @@ class BertAdam(Optimizer):
lr = []
for group in self.param_groups:
for p in group['params']:
if p.grad is None:
continue
state = self.state[p]
if len(state) == 0:
return [0]