MAGICS-LAB / DNABERT_2

[ICLR 2024] DNABERT-2: Efficient Foundation Model and Benchmark for Multi-Species Genome
Apache License 2.0
254 stars 59 forks source link

Unable to Retrieve ' hidden_states ' Despite ' Setting return_dict=True ' and ' output_hidden_states=True ' #85

Open biglittleme opened 4 months ago

biglittleme commented 4 months ago

Hello, I am currently working with the zhihan1996/DNABERT-2-117M model to extract features from DNA sequences and am encountering an issue with accessing the hidden states of the model.

Issue Description Despite setting return_dict=True and output_hidden_states=True, the output from the model remains a tuple rather than the expected ModelOutput object that includes the .hidden_states attribute. When attempting to access outputs.hidden_states, I encounter the following error: AttributeError: 'tuple' object has no attribute 'hidden_states'

Additionally, I have used the following code to check the type and attributes of the output object, confirming that it indeed returns a tuple, which lacks the ' hidden_states ': print(type(outputs)) print(dir(outputs))

Environment Setup Transformers version: 4.29.2 (as specified in the requirements.txt)

I would appreciate any guidance or suggestions on how to resolve this issue. Thank you for your time and assistance!

deylsh commented 4 months ago

We encountered the same issue. It should work if you set the transformer version to 4.28.0 :)

biglittleme commented 4 months ago

Thank you so much for your assistance! I will proceed to update the transformer to the version you suggested. By the way, could you please let me know if there are any other version dependencies that I should be aware of? Your guidance is greatly appreciated!

biglittleme commented 4 months ago

I have set the transformers library to version 4.28.0, but unfortunately, the issue persists.