brightmart / sentiment_analysis_fine_grain Goto Github PK
View Code? Open in Web Editor NEWMulti-label Classification with BERT; Fine Grained Sentiment Analysis from AI challenger
Multi-label Classification with BERT; Fine Grained Sentiment Analysis from AI challenger
Hi
Great work!
Can I ask what f1 scores and performance did you get from running run_classifier_multi_labels_bert.py
?
Thanks
在 bert_model.py 中第92行,
encoder_class = Encoder(self.d_model, self.d_k, self.d_v, self.sequence_length, self.h, self.batch_size,
self.num_layer, self.input_representation, self.input_representation,
dropout_keep_prob=self.dropout_keep_prob,
use_residual_conn=self.use_residual_conn)
参数mask为何没有赋值,意思是默认不用掩模?但编码器中掩模操作是必须的吧。
在 multi_head_attention.py中第82行,
mask = tf.expand_dims(self.mask, axis=-1) # [batch,sequence_length,1]
mask = tf.expand_dims(mask, axis=1) # [batch,1,sequence_length,1]
dot_product = dot_product + mask # [batch,h,sequence_length,1]
掩模操作怎么会是直接相加呢?
Thank you for a nice example, but I bumped into the following error when executing "estimator.train(input_fn=train_input_fn, max_steps=num_train_steps)" in run_classifier_multi_labels_bert.py.
RuntimeError: Attempted to use a closed Session.
Any suggestion?
target lable: [0, 7, 9, 12, 18, 20, 24, 30, 32, 38, 40, 44, 48, 52, 58, 62, 64, 68, 75, 76]
predict lable: [0, 4, 8, 12, 20, 24, 32, 48, 52, 64, 68]
预测时长度小于二十的怎么恢复到20?
我看了一下代码逻辑,由split后的probabilities和labels来计算accuracy, 下面这个代码块中加粗部分是否应该改成label_ids_split=tf.split(label_ids,FLAGS.num_aspects,axis=-1)? 这个是否与其他人po的eval_accuracy出错有关?
`def metric_fn(per_example_loss, label_ids, logits):
#print("###metric_fn.logits:",logits.shape) # (?,80)
#predictions = tf.argmax(logits, axis=-1, output_type=tf.int32)
#print("###metric_fn.label_ids:",label_ids.shape,";predictions:",predictions.shape) # label_ids: (?,80);predictions:(?,)
logits_split=tf.split(logits,FLAGS.num_aspects,axis=-1) # a list. length is num_aspects
label_ids_split=tf.split(logits,FLAGS.num_aspects,axis=-1) # a list. length is num_aspects
accuracy=tf.constant(0.0,dtype=tf.float64)
for j,logits in enumerate(logits_split): #
# accuracy = tf.metrics.accuracy(label_ids, predictions)
predictions=tf.argmax(logits, axis=-1, output_type=tf.int32) # should be [batch_size,]
label_id_=tf.cast(tf.argmax(label_ids_split[j],axis=-1),dtype=tf.int32)
print("label_ids_split[j]:",label_ids_split[j],";predictions:",predictions,";label_id_:",label_id_)
current_accuracy,update_op_accuracy=tf.metrics.accuracy(label_id_,predictions)
accuracy+=tf.cast(current_accuracy,dtype=tf.float64)
accuracy=accuracy/tf.constant(FLAGS.num_aspects,dtype=tf.float64)
loss = tf.metrics.mean(per_example_loss)
return {
"eval_accuracy": (accuracy,update_op_accuracy),
"eval_loss": loss,
}`
https://pan.baidu.com/s/1ZS4dAdOIAe3DaHiwCDrLKw
这里面没有testb测试集,另外testa测试集没有打标呢
我把中文的预训练bert换成英文的bert,就出现了下面的错误,是需要修改什么地方吗?谢谢~
ERROR:tensorflow:Error recorded from evaluation_loop: Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
https://pan.baidu.com/s/1ZS4dAdOIAe3DaHiwCDrLKw
这里面没有testb测试集,另外testa测试集没有打标呢
。。
eval_accuracy = 0.05
eval_loss = 0.1677554
global_step = 78750
loss = 0.16775554
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.