rxn4chemistry / rxn_yields

Code complementing our manuscript on the prediction of chemical reaction yields (https://iopscience.iop.org/article/10.1088/2632-2153/abc81d) and data augmentation strategies (https://doi.org/10.26434/chemrxiv.13286741).
https://rxn4chemistry.github.io/rxn_yields/
MIT License
104 stars 28 forks source link

AttributeError: 'SmilesClassificationModel' object has no attribute 'loss_fct' #15

Open LinPXi opened 1 year ago

LinPXi commented 1 year ago

Hello, I would like to ask you a question, I sent the screenshot, can you take a look at it for me, the first picture is an error report, the second picture is that I slightly changed the code, but the main problem is the first An error message for a picture. AttributeError: 'SmilesClassificationModel' object has no attribute 'loss_fct' image image

LinPXi commented 1 year ago

I would really appreciate it if you could help me out with this.

goftok commented 3 weeks ago

The issue seems to be with the newer version of the transformers library. In the publication, they used simpletransformers==0.34.4 and transformers==2.11.0. Downgrading the packages should solve the issue. Alternatively, you can use newer versions of the packages and set your own loss_fct. For example: pretrained_bert.loss_fct = torch.nn.MSELoss().