-
Notifications
You must be signed in to change notification settings - Fork 34
add emotion_detection and update senta #62
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| def download(url, filename, md5sum): | ||
| """ | ||
| Download file and check md5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是否可以使用现有 download.py 中的 get_path_from_url 呢
| self._encoder = CNNEncoder( | ||
| dict_size=self.dict_dim + 1, | ||
| emb_dim=self.emb_dim, | ||
| seq_len=self.seq_len, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看到这里需要设置seq_len,固定的seq_len对于可能会有些问题,这个的话是CNNEncoder这个API导致的,已经和 @jinyuKING 去更新 #60 中的这个接口了,后面可能还要麻烦再调整下。
| emb_dim=self.emb_dim, | ||
| padding_idx=None, | ||
| bow_dim=self.hid_dim, | ||
| seq_len=self.seq_len) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上,已经和 @jinyuKING 去更新 #60 中的这个接口了,后面可能还要麻烦再调整下
| self._fc_prediction = Linear(input_dim=self.fc_hid_dim, | ||
| output_dim=self.class_dim, | ||
| act="softmax") | ||
| self._encoder = GRUEncoder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#60 中加的这个接口后面会去掉,对于GRU和LSTM后面各提供一个统一的接口,GRU的话可以使用下面BiGRU中一样的接口
|
|
||
| def forward(self, inputs): | ||
| emb = self.embedding(inputs) | ||
| emb = fluid.layers.reshape(emb, shape=[self.batch_size, -1, self.hid_dim]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
类似seq_len,batch_size最后也要支持不同batch间可变,尽量不要固定。这里的话如果inputs是[batch_size, seq_len]的形状的话应该就不需要这个reshape和batch_size的引入了
| emb_dim=self.emb_dim, | ||
| lstm_dim=self.hid_dim, | ||
| hidden_dim=self.hid_dim, | ||
| seq_len=self.seq_len, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LSTMEncoder的话 #60 中加的这个接口后面也会调整,对于GRU和LSTM后面各提供一个统一的接口,还要麻烦后面再调整下
| from paddle.io import DataLoader | ||
|
|
||
|
|
||
| class EmoTectProcessor(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议使用新的 Dataset + BatchSampler + DataLoader 的数据读入方式,可以参考这里 https://github.com/PaddlePaddle/hapi/blob/master/hapi/text/bert/dataloader.py#L162 。时间紧急的话可以后续考虑
| def __init__(self, dict_dim, seq_len): | ||
| super(GRU, self).__init__() | ||
| self.dict_dim = dict_dim | ||
| self.emb_dim = 128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议参数尽量可配置,可以后续考虑
| self.class_dim = 3 | ||
| self.seq_len = seq_len | ||
| self._fc1 = Linear(input_dim=self.hid_dim, output_dim=self.fc_hid_dim, act="tanh") | ||
| self._fc_prediction = Linear(input_dim=self.fc_hid_dim, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看CNN、BOW和下面的LSTM中几个中也都是包含了_fc1, _fc_prediction, 后续可以考虑把不同特征提取部分抽出来
No description provided.