Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
biglittleme opened this issue May 7, 2024 · 3 comments

Comments

@biglittleme
Copy link

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
Copy link

deylsh commented May 8, 2024

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

@biglittleme
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants