SilyRab / AoM

Codes for AoM: Detecting Aspect-oriented Information for Multimodal Aspect-Based Sentiment Analysis
35 stars 4 forks source link

关于直接推理的模型 #19

Open WAYSC opened 7 months ago

WAYSC commented 7 months ago

周茹老师您好!当我使用no_train参数的时候,加载的模型是AoM-ckpt/Twitter2015/AoM.pt,加载的数据是测试集数据,一共有43个batch,但是为什么测试结果仍然是0呢? TEST aesc_p:0.0 aesc_r:0.0 aesc_f:0.0 TEST ae_p:0.0 ae_r:0.0 ae_f:0.0 TEST sc_p:0.0 sc_r:0.0 sc_f:0.0 请问有没有可以直接用于推理的模型,能直接在测试集上推理呢?

SilyRab commented 7 months ago

是用的论文中的数据集吗,按道理不应该啊

WAYSC commented 7 months ago

是用的论文中的数据集吗,按道理不应该啊

用的数据集就是twitter15和twitter17,刚刚我又试了试17,打印了预测的span: pred tensor([[0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1]], device='cuda:3') 17的实验配置: ============ Initialed with 1 GPU(s) ============= dataset: [['twitter17', './src/data/jsons/twitter17_info.json']] device: cpu checkpoint_dir: ./train17 bart_model: ./bart_model log_dir: 17_aesc model_config: config/pretrain_base.json text_only: False checkpoint: ./checkpoint/pytorch_model.bin lr_decay_every: 4 lr_decay_ratio: 0.8 epochs: 35 eval_every: 1 eval_step: 50 lr: 7.5e-05 num_beams: 4 continue_training: False warmup: 0.1 dropout: None classif_dropout: None attention_dropout: None activation_dropout: None grad_clip: 5.0 gpu_num: 1 cpu: False amp: False master_port: 12355 batch_size: 16 seed: 28 num_workers: 0 max_len: 10 max_len_a: 0.6 bart_init: 1 check_info: is_check: 1 task: rank: 3 no_train: True trc_pretrain_file: TRC_ckpt/pytorch_model.bin encoder: None sentinet_on: True nn_attention_on: True nn_attention_mode: cat trc_on: True gcn_on: True gcn_dropout: 0 gcn_proportion: 0.5 dep_mode: text_cos_img_noun_sim img_path: src/data/twitter2017_images checkpoint_path: ./train17/2024-04-10-10-45-33 Loading model... self.bos_token_id 0 self.eos_token_id 2 self.pad_token_id 1 {'AESC': 50281, 'POS': 50276, 'NEU': 50277, 'NEG': 50278} num_tokens 50265 Loading data...

这是15的实验配置: ============ Initialed with 1 GPU(s) ============= dataset: [['twitter15', './src/data/jsons/twitter15_info.json']] device: cpu checkpoint_dir: ./train15 bart_model: ./bart_model log_dir: 15_aesc model_config: config/pretrain_base.json text_only: False checkpoint: ./checkpoint/pytorch_model.bin lr_decay_every: 4 lr_decay_ratio: 0.8 epochs: 35 eval_every: 1 eval_step: 50 lr: 7.5e-05 num_beams: 4 continue_training: False warmup: 0.1 dropout: None classif_dropout: None attention_dropout: None activation_dropout: None grad_clip: 5.0 gpu_num: 1 cpu: False amp: False master_port: 12355 batch_size: 16 seed: 57 num_workers: 0 max_len: 10 max_len_a: 0.6 bart_init: 1 check_info: is_check: 1 task: rank: 3 no_train: True trc_pretrain_file: ./TRC_ckpt/pytorch_model.bin encoder: None sentinet_on: True nn_attention_on: True nn_attention_mode: cat trc_on: True gcn_on: True gcn_dropout: 0 gcn_proportion: 0.5 dep_mode: text_cos_img_noun_sim img_path: src/data/twitter2015_images checkpoint_path: ./train15/2024-04-10-10-46-24 Loading model... self.bos_token_id 0 self.eos_token_id 2 self.pad_token_id 1 {'AESC': 50281, 'POS': 50276, 'NEU': 50277, 'NEG': 50278} num_tokens 50265 Loading data...

请老师有空的时候帮忙看看是哪里的设置出了问题~~

SilyRab commented 7 months ago

你是只想做方面词提取吗,输出有问题。而且看配置用的cpu,怎么打印出来的是用的gpu cuda 3

WAYSC commented 7 months ago

你是只想做方面词提取吗,输出有问题。而且看配置用的cpu,怎么打印出来的是用的gpu cuda 3

我想试试直接推理的aesc效果,不知道是哪里出了问题,预测的span一直都是: ps [2, 2, 1, 1]

最开始打印的device:cpu是因为: parser.add_argument('--device', default='cpu', type=str, help=' ') 我使用的就是cuda3,因为我在sh文件中设置了rank为3, --rank 3 \ 后面打印的也没有问题: gpu_num: 1 cpu: False

SilyRab commented 7 months ago

目标span正常吗

SilyRab commented 7 months ago

改过代码和一些超参吗

WAYSC commented 7 months ago

目标span正常吗

目标span正常: 这是第 1 次 pred tensor([[0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1], [0, 2, 2, 1, 1]], device='cuda:3') ts [[24, 24, 4]] ps [2, 2, 1, 1] ts [[11, 11, 3]] ps [2, 2, 1, 1] ts [[24, 25, 4]] ps [2, 2, 1, 1] ts [[14, 15, 4]] ps [2, 2, 1, 1] ts [[17, 20, 4]] ps [2, 2, 1, 1] ts [[20, 20, 3]] ps [2, 2, 1, 1] ts [[16, 16, 4]] ps [2, 2, 1, 1] ts [[17, 17, 4], [20, 20, 4]] ps [2, 2, 1, 1] ts [[13, 16, 3]] ps [2, 2, 1, 1] ts [[21, 21, 4]] ps [2, 2, 1, 1] ts [[16, 19, 4]] ps [2, 2, 1, 1] ts [[14, 15, 4], [22, 22, 5]] ps [2, 2, 1, 1] ts [[28, 29, 4]] ps [2, 2, 1, 1] ts [[21, 21, 4]] ps [2, 2, 1, 1] ts [[12, 13, 4], [18, 19, 5]] ps [2, 2, 1, 1] ts [[15, 16, 5]] ps [2, 2, 1, 1]

WAYSC commented 7 months ago

改过代码和一些超参吗

没有改动,我特地又检查了一遍,代码和设置都是按照github最新内容设置的~

ccflyu commented 1 week ago

改过代码和一些超参吗

没有改动,我特地又检查了一遍,代码和设置都是按照github最新内容设置的~ 请问您解决这个问题了吗?