-
Notifications
You must be signed in to change notification settings - Fork 161
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: 'ATEPCConfigManager' object has no attribute 'hidden_dim' #397
Comments
and when i add "config.hidden_dim = 768" |
Please make sure that your datasets contains the same number of the labels as the pretrained model you are going to use. If the number of labels are not equal, please try fine-tuning the model based on merely your own dataset. |
Hello, thank you very much for your answer. |
Thanks for your suggestion, after modifying self.output_dim, my code runs well. Is this because the result of the pre-trained model is a triplet of this type? But my data is consistent with the data structure of the pre-trained model. |
Version
See the console output for PyABSA, Torch, Transformers Version
2.4.1.post1
Describe the bug
A clear and concise description of what the bug is.
Traceback (most recent call last):
File "D:\anaconda\envs\pyabsa2\lib\site-packages\pyabsa\framework\configuration_class\configuration_template.py", line 45, in getattribute
value = super().getattribute("args")[arg_name]
KeyError: 'hidden_dim'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\PyABSA-2\yelp\test.py", line 56, in
trainer = ATEPC.ATEPCTrainer(
File "D:\anaconda\envs\pyabsa2\lib\site-packages\pyabsa\tasks\AspectTermExtraction\trainer\atepc_trainer.py", line 69, in init
self._run()
File "D:\anaconda\envs\pyabsa2\lib\site-packages\pyabsa\framework\trainer_class\trainer_template.py", line 240, in _run
model_path.append(self.training_instructor(self.config).run())
File "D:\anaconda\envs\pyabsa2\lib\site-packages\pyabsa\tasks\AspectTermExtraction\instructor\atepc_instructor.py", line 40, in init
self._load_dataset_and_prepare_dataloader()
File "D:\anaconda\envs\pyabsa2\lib\site-packages\pyabsa\tasks\AspectTermExtraction\instructor\atepc_instructor.py", line 252, in load_dataset_and_prepare_dataloader
self.model = self.config.model(self.bert_base_model, config=self.config)
File "D:\anaconda\envs\pyabsa2\lib\site-packages\pyabsa\tasks\AspectTermExtraction\models_lcf\fast_lcf_atepc.py", line 31, in init
self.linear_double = nn.Linear(config.hidden_dim * 2, config.hidden_dim)
File "D:\anaconda\envs\pyabsa2\lib\site-packages\pyabsa\framework\configuration_class\configuration_template.py", line 52, in getattribute
return super().getattribute(arg_name)
AttributeError: 'ATEPCConfigManager' object has no attribute 'hidden_dim'
Code To Reproduce
Paste buggy code here
from pyabsa import DatasetItem
my_dataset = DatasetItem("atepc_datasets", ["428.test"])
my_dataset1 and my_dataset2 are the dataset folders. In there folders, the train dataset is necessary
dataset = my_dataset
print(dataset)
from pyabsa import *
config = (
ATEPC.ATEPCConfigManager.get_atepc_config_english()
) # this config contains 'pretrained_bert', it is based on pretrained models
config.model = ATEPC.ATEPCModelList.FAST_LCF_ATEPC # improved version of LCF-ATEPC
from pyabsa import ModelSaveOption, DeviceTypeOption
import warnings
warnings.filterwarnings("ignore")
config.batch_size = 16
config.patience = 2
config.log_step = -1
config.seed = [1]
config.verbose = False # If verbose == True, PyABSA will output the model strcture and seversal processed data examples
config.notice = (
"This is an training example for aspect term extraction" # for memos usage
)
trainer = ATEPC.ATEPCTrainer(
config=config,
dataset=dataset,
from_checkpoint="English",# 不想基于预训练模型的话,删掉这行(还是建议用)
auto_device=DeviceTypeOption.AUTO, # use cuda if available
checkpoint_save_mode=ModelSaveOption.SAVE_MODEL_STATE_DICT, # save state dict only instead of the whole model
load_aug=False, # there are some augmentation dataset for integrated datasets, you use them by setting load_aug=True to improve performance
)
aspect_extractor = trainer.load_trained_model()
assert isinstance(aspect_extractor, ATEPC.AspectExtractor)
Expected behavior
I want to make small adjustments based on your own data
Thank you for your answering!
The text was updated successfully, but these errors were encountered: