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

AttributeError: 'GEARS' object has no attribute 'best_model' #60

Open
Mimianmy opened this issue Oct 2, 2024 · 0 comments
Open

AttributeError: 'GEARS' object has no attribute 'best_model' #60

Mimianmy opened this issue Oct 2, 2024 · 0 comments

Comments

@Mimianmy
Copy link

Mimianmy commented Oct 2, 2024

Hello,

I have successfully reproduced all the steps up to the point before the testing phase, as shown in the provided plots, and everything was working without any errors. However, when I reached the testing step, I encountered the following error:
AttributeError: 'GEARS' object has no attribute 'best_model'
Error1002

I am unsure why this error occurs, as the code leading up to this point seems to work as expected. I am initializing the model with the following code:

Check if model and best_model are properly initialized

if not hasattr(gears_model, 'model') or gears_model.model is None:
gears_model.model_initialize() # Initialize model if not already done

if not hasattr(gears_model, 'best_model') or gears_model.best_model is None:
gears_model.best_model = gears_model.model.to(gears_model.device) # Initialize best_model

Continue with evaluation

test_res = evaluate(
gears_model.dataloader['test_loader'],
gears_model.best_model,
gears_model.config['uncertainty'],
gears_model.device
)

I suspect the issue might be related to how best_model or model is initialized or used within the class. In the class definition, self.config = None is set in the constructor (init), and self.model = GEARS_Model(self.config).to(self.device) is assigned in the model_initialize function.

Would you be able to provide any insights on what might be causing the error or how to correctly initialize best_model?

Thank you for your help!

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

1 participant