songyouwei / ABSA-PyTorch

Aspect Based Sentiment Analysis, PyTorch Implementations. 基于方面的情感分析,使用PyTorch实现。
MIT License
2.01k stars 524 forks source link

请问IAN模型中text_raw_indices, aspect_indices是代表什么意思呢? #118

Open Summer-1994 opened 4 years ago

Summer-1994 commented 4 years ago

为什们求sum要有 text_raw_indices !=0 aspect_indices !=0 呢?

songyouwei commented 4 years ago

@Summer-1994 text_raw_indices, aspect_indices 分别是原文本和aspect文本映射到词表id的序列 https://github.com/songyouwei/ABSA-PyTorch/blob/06ed21091dee8e85317ee0e6d665be49236a688d/data_utils.py#L137

!=0是因为词表id从1开始编号,而序列在做padding的时候填充的都是0 https://github.com/songyouwei/ABSA-PyTorch/blob/06ed21091dee8e85317ee0e6d665be49236a688d/data_utils.py#L86 https://github.com/songyouwei/ABSA-PyTorch/blob/06ed21091dee8e85317ee0e6d665be49236a688d/data_utils.py#L66

Summer-1994 commented 4 years ago

太感谢您啦~