Loading a converted pytorch model in huggingface transformers properly
# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->
I converted a pre-trained tf model to pytorch using the following function.
```
def convert_tf_checkpoint_to_pytorch(*, tf_checkpoint_path, albert_config_file, pytorch_dump_path):
    # Initialise PyTorch model
    config = AlbertConfig.from_json_file(albert_config_file)
    print("Building PyTorch model from configuration: {}".format(str(config)))
    model = AlbertForPreTraining(config)

    # Load weights from tf checkpoint
    load_tf_weights_in_albert(model, config, tf_checkpoint_path)

    # Save pytorch-model
    print("Save PyTorch model to {}".format(pytorch_dump_path))
    torch.save(model.state_dict(), pytorch_dump_path)
```
I am loading the converted model and encoding sentences in the following way:
```
def vectorize_sentence(text):
    albert_tokenizer = AlbertTokenizer.from_pretrained("albert-base-v2")
    config = AlbertConfig.from_pretrained(config_path, output_hidden_states=True)
    model = TFAlbertModel.from_pretrained(pytorch_dir, config=config, from_pt=True)
    e = albert_tokenizer.encode(text, max_length=512)
    model_input = tf.constant(e)[None, :]  # Batch size 1
    output = model(model_input)

    v = [0] * 768
    # generate sentence vectors by averaging the word vectors
    for i in range(1, len(model_input[0]) - 1):
        v = v + output[0][0][i].numpy()

    vector = v/len(model_input[0])
    return vector
```
However while loading the model, a warning comes up: 

> Some weights or buffers of the PyTorch model TFAlbertModel were not
> initialized from the TF 2.0 model and are newly initialized:
> ['predictions.LayerNorm.bias', 'predictions.dense.weight',
> 'predictions.LayerNorm.weight', 'sop_classifier.classifier.bias',
> 'predictions.dense.bias', 'sop_classifier.classifier.weight',
> 'predictions.decoder.bias', 'predictions.bias',
> 'predictions.decoder.weight'] You should probably TRAIN this model on
> a down-stream task to be able to use it for predictions and inference.


Can anyone tell me if I am doing anything wrong? What does the warning mean? I saw issue #5588. Don't know if my issue is the same as this.

<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on the forum/Stack Overflow**:
https://stackoverflow.com/questions/63648380/loading-a-converted-pytorch-model-in-huggingface-transformers-properly
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
