Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix naming in TF MobileBERT #10095

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/transformers/models/mobilebert/modeling_tf_mobilebert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,18 +1105,17 @@ class TFMobileBertForMaskedLM(TFMobileBertPreTrainedModel, TFMaskedLanguageModel
_keys_to_ignore_on_load_unexpected = [
r"pooler",
r"seq_relationship___cls",
r"predictions___cls",
r"cls.seq_relationship",
]

def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)

self.mobilebert = TFMobileBertMainLayer(config, add_pooling_layer=False, name="mobilebert")
self.mlm = TFMobileBertMLMHead(config, name="mlm___cls")
self.predictions = TFMobileBertMLMHead(config, name="predictions___cls")

def get_lm_head(self):
return self.mlm.predictions
return self.predictions.predictions

def get_prefix_bias_name(self):
warnings.warn("The method get_prefix_bias_name is deprecated. Please use `get_bias` instead.", FutureWarning)
Expand Down Expand Up @@ -1179,7 +1178,7 @@ def call(
training=inputs["training"],
)
sequence_output = outputs[0]
prediction_scores = self.mlm(sequence_output, training=inputs["training"])
prediction_scores = self.predictions(sequence_output, training=inputs["training"])

loss = None if inputs["labels"] is None else self.compute_loss(inputs["labels"], prediction_scores)

Expand Down