This repository was archived by the owner on Nov 12, 2025. It is now read-only.
Train K Fold not working for LCF_BERT#207
Open
joaoaleite wants to merge 2 commits intosongyouwei:masterfrom
Open
Train K Fold not working for LCF_BERT#207joaoaleite wants to merge 2 commits intosongyouwei:masterfrom
joaoaleite wants to merge 2 commits intosongyouwei:masterfrom
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trying to run K-fold cross validation for lcf-bert yields this error message:
Traceback (most recent call last):
File "train_k_fold_cross_val.py", line 315, in
main()
File "train_k_fold_cross_val.py", line 311, in main
ins.run()
File "train_k_fold_cross_val.py", line 181, in run
self._reset_params()
File "train_k_fold_cross_val.py", line 84, in _reset_params
self.model.bert.load_state_dict(self.pretrained_bert_state_dict)
File "/Users/joaoleite/anaconda3/envs/absa/lib/python3.6/site-packages/torch/nn/modules/module.py", line 576, in getattr
type(self).name, name))
AttributeError: 'LCF_BERT' object has no attribute 'bert'
I've noticed the _reset_params function in both train.py and train_k_fold_cross_val.py are exactly the same, apart from this else statement:
else:
self.model.bert.load_state_dict(self.pretrained_bert_state_dict)
So I removed it and it worked just fine. Tested for LCF-BERT and BERT_SPC.
Also, I've noticed that running "pip install -r requirements.txt" installs pytorch==1.10.x", which is incompatible. I've added an upper limit of <=1.4.0 and it works.