brightmart / text_classification

all kinds of text classification models and more with deep learning
MIT License
7.83k stars 2.57k forks source link

p1_HierarchicalAttention_model_transformer.py #71

Closed yangdelu855 closed 6 years ago

yangdelu855 commented 6 years ago

I have tried your code in text classification in github. Thanks for your sharing. However, I come across with a problem when running the test code in “a05_HierarchicalAttentionNetwork/p1_HierarchicalAttention_model_transformer.py”. In the test code, you have set all the input docs the same. But why the model can predict diffirent label for the docs with same content? And why the accurracy will become 1 after a few iterations? Also, we find that when we give a different input content with same labels in the HAN model, we always get a same result on the test dataset. Looking forword for your reply.

brightmart commented 6 years ago

hi,

input_x = np.zeros((batch_size, sequence_length))

-->should be input_x = np.random.randn((batch_size, sequence_length))

test() function is used to check whether model can run without error, and if possible,

we want to show that model can have some ability to learn simple task in a very short time.

so you can design a new input and output as a toy task.

I used this model for a text classification task, it can works. so you may try to let the model pass toy task first.

toy task: I've just updated this file.


发件人: dulusir notifications@github.com 发送时间: 2018年7月18日 16:18 收件人: brightmart/text_classification 抄送: Subscribed 主题: [brightmart/text_classification] p1_HierarchicalAttention_model_transformer.py (#71)

I have tried your code in text classification in github. Thanks for your sharing. However, I come across with a problem when running the test code in “a05_HierarchicalAttentionNetwork/p1_HierarchicalAttention_model_transformer.py”. In the test code, you have set all the input docs the same. But why the model can predict diffirent label for the docs with same content? And why the accurracy will become 1 after a few iterations? Also, we find that when we give a different input content with same labels in the HAN model, we always get a same result on the test dataset. Looking forword for your reply.

― You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/brightmart/text_classification/issues/71, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ASuYMCgDdRw2DhGfdox0clAepyJ0omqEks5uHu9YgaJpZM4VUJY7.

yangdelu855 commented 6 years ago

In your previous test function, given 10 samples with same content(all zeros) but different labels in a batch, we train the model for several times, the acc can arrive 100%. I just wonder, how the model tells the docs with all zeros from each other, and predict different labels for them?Is there anything wrong? 3aef5ee3-d45b-4df3-b958-2eef3083359f 8c2ca29f-d30a-4464-8229-2e35b1d48ae9