brightmart / text_classification

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

HierarchicalAttentionNetwork #95

Closed sftekin closed 5 years ago

sftekin commented 5 years ago

Hi, would you please update this model too? Thanks...

brightmart commented 5 years ago

yeah. no problem, within this week. however, before it you can still able to run it by: 1) download cached file. Sample data:

Sample data: cached file

2) follow a00_Bert/train_bert_multi-label.py

add two hyper-parameter:

tf.app.flags.DEFINE_string("cache_file_h5py","../data/ieee_zhihu_cup/data.h5","path of training/validation/test data.") #../data/sample_multiple_label.txt

tf.app.flags.DEFINE_string("cache_file_pickle","../data/ieee_zhihu_cup/vocab_label.pik","path of vocabulary and label files") #../data/sample_multiple_label.txt

add two lines to load data:

get training data and vocabulary & labels dict by: word2index, label2index, trainX, trainY, vaildX, vaildY, testX, testY = load_data(FLAGS.cache_file_h5py,FLAGS.cache_file_pickle)

vocab_size = len(word2index); print("bert model.vocab_size:", vocab_size);

num_labels = len(label2index); print("num_labels:", num_labels); cls_id=word2index['CLS'];print("id of 'CLS':",word2index['CLS'])

num_examples, FLAGS.max_seq_length = trainX.shape;print("num_examples of training:", num_examples, ";max_seq_length:", FLAGS.max_seq_length)
sftekin commented 5 years ago

Thank you very much