You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class RerankerModel(nn.Module):
TRANSFORMER_CLS = AutoModelForSequenceClassification
def __init__(self, hf_model: PreTrainedModel, train_batch_size: int = None):
super().__init__()
self.config = hf_model.config
self.hf_model = hf_model
self.train_batch_size = train_batch_size
self.cross_entropy = nn.CrossEntropyLoss(reduction='mean')
if train_batch_size:
self.register_buffer(
'target_label',
torch.zeros(self.train_batch_size, dtype=torch.long, device=self.hf_model.device)
)
for name, param in self.hf_model.named_parameters():
# for some reason, ds zero 3 left some weights empty
if 'modules_to_save' in name and param.numel() == 0:
logger.warning(f'parameter {name}, shape {param.shape} is empty')
param.data = nn.Linear(self.hf_model.config.hidden_size, 1).weight.data
logger.warning('{} data: {}'.format(name, param.data.cpu().numpy()))
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: