"vscode:/vscode.git/clone" did not exist on "485d913dfbf61a1af4d78aa5038f0007805908cb"
Unverified Commit aa018a79 authored by Patrick von Platen's avatar Patrick von Platen Committed by GitHub
Browse files

up (#13777)

parent a21ee1f9
...@@ -964,6 +964,14 @@ class HubertForCTC(HubertPreTrainedModel): ...@@ -964,6 +964,14 @@ class HubertForCTC(HubertPreTrainedModel):
self.hubert = HubertModel(config) self.hubert = HubertModel(config)
self.dropout = nn.Dropout(config.final_dropout) self.dropout = nn.Dropout(config.final_dropout)
if config.vocab_size is None:
raise ValueError(
f"You are trying to instantiate {self.__class__} with a configuration that "
"does not define the vocabulary size of the language model head. Please "
"instantiate the model as follows: `HubertForCTC.from_pretrained(..., vocab_size=vocab_size)`. "
"or define `vocab_size` of your model's configuration."
)
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size) self.lm_head = nn.Linear(config.hidden_size, config.vocab_size)
self.init_weights() self.init_weights()
......
...@@ -1416,6 +1416,14 @@ class Wav2Vec2ForCTC(Wav2Vec2PreTrainedModel): ...@@ -1416,6 +1416,14 @@ class Wav2Vec2ForCTC(Wav2Vec2PreTrainedModel):
self.wav2vec2 = Wav2Vec2Model(config) self.wav2vec2 = Wav2Vec2Model(config)
self.dropout = nn.Dropout(config.final_dropout) self.dropout = nn.Dropout(config.final_dropout)
if config.vocab_size is None:
raise ValueError(
f"You are trying to instantiate {self.__class__} with a configuration that "
"does not define the vocabulary size of the language model head. Please "
"instantiate the model as follows: `Wav2Vec2ForCTC.from_pretrained(..., vocab_size=vocab_size)`."
"or define `vocab_size` of your model's configuration."
)
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size) self.lm_head = nn.Linear(config.hidden_size, config.vocab_size)
self.init_weights() self.init_weights()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment