Closed hamzaakramsybrid closed 2 years ago
Hello,
I notice this problem, this error occurs in above 1.2.7 version, please roll back to 1.2.6 by pip install pyabsa==1.2.6 and use the demo scripts with commit tag "1.2.6".
I will revert the last commit on github to fix the demo scripts, please mind the commit tag.
Please follow the latest demo scripts and version 1.2.8, and feel free to report any problem. Thanks!
I have tried version 1.2.8 but I am still getting the same error.
Can you show me your entire script?
from pyabsa.functional import Trainer from pyabsa.functional import APCConfigManager from pyabsa.functional import ABSADatasetList
from pyabsa.functional import APCModelList
apc_config_english = APCConfigManager.get_apc_config_english()
apc_config_english.model = APCModelList.SLIDE_LCFS_BERT
apc_config_english.similarity_threshold = 1 apc_config_english.max_seq_len = 80 apc_config_english.dropout = 0.5 apc_config_english.log_step = 5 apc_config_english.num_epoch = 5 apc_config_english.evaluate_begin = 4 apc_config_english.l2reg = 0.0005 apc_config_english.seed = {1, 2, 3} apc_config_english.cross_validate_fold = -1
dataset_path = ABSADatasetList.SemEval #or set your local dataset print(dataset_path) sent_classifier = Trainer(config=apc_config_english, dataset=dataset_path, # train set and test set will be automatically detected checkpoint_save_mode=1, # = None to avoid save model auto_device=True # automatic choose CUDA or CPU )
inference_dataset = ABSADatasetList.SemEval # or set your local dataset results = sent_classifier.batch_infer(target_file=inference_dataset, print_result=True, save_result=True, ignore_error=True, )
I am following the quick start of Aspect Polarity Classification while changing the num_epoch to 5 from 10.
The usage in the readme is outdated, please follow the specific demo scripts.
This release-note of 1.2.8 indicates that we should use Trainer().load_trained_model() to get the inference model:
sent_classifier = Trainer(config=apc_config_english,
dataset=dataset_path, # train set and test set will be automatically detected
checkpoint_save_mode=1, # = None to avoid save model
auto_device=True # automatic choose CUDA or CPU
).load_trained_model()
It's working now. I am using load_trained_model() function then I am able to use batch_infer function to get the results. Thank you.
Hello dear, I hope you are fine. First of all, thank you so much for your great effort in this repository. I am following the quickstart of Aspect Polarity Classification in which I have trained the APCModelList.SLIDE_LCFS_BERT model with 5 epochs. After 5 epochs when I run the 5th block of sentiment inference it gave me the error given below. I tried to locate the function batch_infer in Trainer class but could not find it. Maybe I am mistaken but kindly resolve this issue and guide me. Thank you
Aspect Polarity Classification
APCModelList.SLIDE_LCFS_BERT
SemEval
AttributeError: 'Trainer' object has no attribute 'batch_infer' AttributeError Traceback (most recent call last)