# Wav2Vec2ForCTC.from\_pretrained for already trained Models?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwav2vec2forctc-from-pretrained-for-already-trained-models%2F5716%3E%5C
**Category:** Beginners\
**Created:** [April 23, 2021, 8:50am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwav2vec2forctc-from-pretrained-for-already-trained-models%2F5716 "2021-04-23T08:50:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknownTransformer](https://avatars.discourse-cdn.com/v4/letter/u/9f8e36/32.png) [@unknownTransformer](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FunknownTransformer)%5C
**Post date:** [April 23, 2021, 8:50am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwav2vec2forctc-from-pretrained-for-already-trained-models%2F5716%2F1 "2021-04-23T08:50:23Z")

</div>

Hi Guys,  
how do i further train a Model someone else already fine-tuned? I wanted to load a already Fine-Tuned Modell like this:

```python
    model = Wav2Vec2ForCTC.from_pretrained(
        model_args.model_name_or_path,
        cache_dir=model_args.cache_dir,
        activation_dropout=model_args.activation_dropout,
        attention_dropout=model_args.attention_dropout,
        hidden_dropout=model_args.hidden_dropout,
        feat_proj_dropout=model_args.feat_proj_dropout,
        mask_time_prob=model_args.mask_time_prob,
        gradient_checkpointing=model_args.gradient_checkpointing,
        layerdrop=model_args.layerdrop,
        ctc_loss_reduction="mean",
        pad_token_id=processor.tokenizer.pad_token_id,
        vocab_size=len(processor.tokenizer),
    )

```

But im getting:

```auto
RuntimeError: Error(s) in loading state_dict for Wav2Vec2ForCTC:
	size mismatch for lm_head.weight: copying a param with shape torch.Size([174, 1024]) from checkpoint, the shape in current model is torch.Size([35, 1024]).
	size mismatch for lm_head.bias: copying a param with shape torch.Size([174]) from checkpoint, the shape in current model is torch.Size([35]).

```

How would i do this right?

Something like

```python
    model = Wav2Vec2ForCTC.from_pretrained(model_args.model_name_or_path)
    model.to("cuda")
    model.freeze_feature_extractor()
    processor = Wav2Vec2Processor.from_pretrained(model_args.model_name_or_path)

```

But im not sure if this is the way to go.

Ty in advanced

---

<div class="post-metadata">

**Author:** ![adilism](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@adilism](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fadilism)%5C
**Post date:** [May 17, 2021, 3:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwav2vec2forctc-from-pretrained-for-already-trained-models%2F5716%2F2 "2021-05-17T15:02:50Z")

</div>

It seems like your vocabulary size does not match the vocab size from the original model. You can remove the old LM head manually and initialise a new one:

```auto
state_dict = torch.load(f"{model_args.model_name_or_path}/pytorch_model.bin", map_location='cpu')
state_dict.pop('lm_head.weight')
state_dict.pop('lm_head.bias')

model = Wav2Vec2ForCTC.from_pretrained(
        model_args.model_name_or_path,
        state_dict=state_dict,
        ...
    )
```
