Check for None

This commit is contained in:
LysandreJik
2019-08-31 00:56:22 -04:00
parent e0f867a9ba
commit ea86bef545

View File

@@ -327,7 +327,7 @@ class PreTrainedModel(nn.Module):
else: else:
first_module.weight = second_module.weight first_module.weight = second_module.weight
if hasattr(first_module, 'bias'): if hasattr(first_module, 'bias') and first_module.bias is not None:
first_module.bias.data = torch.nn.functional.pad( first_module.bias.data = torch.nn.functional.pad(
first_module.bias.data, first_module.bias.data,
(0, first_module.weight.shape[0] - first_module.bias.shape[0]), (0, first_module.weight.shape[0] - first_module.bias.shape[0]),