Skip to content

Chemberta model produces random output for embeddings, it depends on seed #13

@GenerateIdea

Description

@GenerateIdea

Dear Alexander Kroll

In the file https://github.com/bayer-int/pbt-dsa-gds-cmd-ProSmith/tree/main/code/preprocessing/smiles_embeddings.py there are the logits produced. However, if I load the Chemberta model twice, it produces different outputs. If I fix a seed it produces always the same output. However, the logits produced should be constant.

The layer head.dense.weight is not initialized with user-supplied weights and produce some random different embedding everytime we load it.

In the respective model file from "DeepChem/ChemBERTa-77M-MTR": "pytorch_model.bin" you can see that one of the layers has the correct size and naming "regression.dense.weight" with dimension 384x384. It seems not correctly set in the instantiated model. However, it can be easily assigned by using:

smiles_bert.lm_head.dense.weight= torch.nn.Parameter( model["regression.dense.weight"])

Please let us know if this is correct.

Currently I am running transformers=4.27.2 and had the same issues with newer versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions