MCPcopy Create free account

hub / github.com/brightmart/bert_language_understanding / functions

Functions125 in github.com/brightmart/bert_language_understanding

↓ 6 callersFunctionget_data_as_array
get data as array :param X_mask_lm_train: :param y_mask_lm_train: :param p_mask_lm_train: :return:
pretrain_task.py:272
↓ 4 callersMethodencoder_fn
use transformer encoder to encode the input, output a sequence. input: [batch_size,sequence_length,d_embedding] :return: output:[bat
model/encoder.py:31
↓ 3 callersFunctionassign_pretrained_word_embedding
assign pretrained word embedding :param sess: :param vocabulary_index2word: :param vocab_size: :param model: :param word2vec_
data_util_hdf5.py:424
↓ 3 callersFunctioncompute_f1
compute f1 :param TP_micro: number.e.g. 200 :param FP_micro: number.e.g. 200 :param FN_micro: number.e.g. 200 :return: f1_score:
evaluation_matrix.py:205
↓ 3 callersFunctioncreate_or_load_vocabulary
create or load vocabulary and label using training data. process as: load from cache if exist; load data, count and get vocabularies and labe
data_util_hdf5.py:212
↓ 3 callersFunctiondo_eval
do evaluation using validation set, and report loss, and f1 score. :param sess: :param model: :param valid: :param num_classes:
train_bert_fine_tuning.py:153
↓ 3 callersFunctiondo_eval
do evaluation using validation set, and report loss, and f1 score. :param sess: :param model: :param valid: :param num_classes:
train_transform.py:140
↓ 3 callersFunctionget_input_strings_and_labels
get input strings and labels by passing a line of raw input. :param line: :return:
data_util_hdf5.py:324
↓ 3 callersFunctionread_file
read file, and return lines :param file_path: path of ifle :return: lines, a list
data_util_hdf5.py:129
↓ 3 callersFunctionset_config
(FLAGS,num_classes,vocab_size)
data_util_hdf5.py:491
↓ 3 callersFunctiontransform_data_to_fasttext_format
(file_path,target_path,data_type)
temp_covert.py:8
↓ 2 callersFunctioncompute_confuse_matrix_batch
compute confuse matrix for a batch :param y_targetlabel_list: a list; each element is a mulit-hot,e.g. [1,0,0,1,...] :param y_logits_arra
evaluation_matrix.py:12
↓ 2 callersFunctioncompute_death_lifeimprisonment_score
compute score for death or life imprisonment :param target: a list :param predict: an array :return: score: a scalar
evaluation_matrix.py:95
↓ 2 callersFunctioncompute_f1_score_write_for_debug
compute f1 score. basicly you can also use other function to get result :param label_dict: {label:(TP,FP,FN)} :return: a dict. key is lab
evaluation_matrix.py:176
↓ 2 callersFunctioncompute_micro_macro
compute f1 of micro and macro :param label_dict: :return: f1_micro,f1_macro: scalar, scalar
evaluation_matrix.py:137
↓ 2 callersMethodconv_layers_return_2layers
main computation graph here: 1.embedding-->2.CONV-RELU-MAX_POOLING-->3.linear classifier
model/bert_cnn_model.py:193
↓ 2 callersFunctiongenerate_label
generate label with input :param input_x: shape of [batch_size, sequence_length] :return: y:[batch_size]
model/bert_cnn_model.py:353
↓ 2 callersFunctiongenerate_label
generate label with input :param input_x: shape of [batch_size, sequence_length] :return: y:[batch_size]
model/transfomer_model.py:175
↓ 2 callersFunctiongenerate_label
generate label with input :param input_x: shape of [batch_size, sequence_length] :return: y:[batch_size]
model/bert_model.py:265
↓ 2 callersFunctioninit_label_dict
init label dict. this dict will be used to save TP,FP,FN :param num_classes: :return: label_dict: a dict. {label_index:(0,0,0)}
evaluation_matrix.py:235
↓ 2 callersMethodlayer_norm_residual_connection
(self)
model/layer_norm_residual_conn.py:16
↓ 2 callersMethodlayer_normalization
x should be:[batch_size,sequence_length,d_model] :return:
model/layer_norm_residual_conn.py:30
↓ 2 callersFunctionload_data_multilabel
convert data as indexes using word2index dicts. 1) use cache file if exist; 2) read source files; 3)transform to train/valid data to standard
data_util_hdf5.py:47
↓ 2 callersMethodmulti_head_attention_fn
multi head attention :param Q: query. shape:[batch,sequence_length,d_model] :param K_s: keys. shape:[batch,sequence_length,d
model/multi_head_attention.py:33
↓ 2 callersMethodposition_wise_feed_forward_fn
positional wise fully connected feed forward implement as two layers of cnn x: [batch,sequence_length,d_model] :return:
model/poistion_wise_feed_forward.py:33
↓ 2 callersMethodsub_layer_layer_norm_residual_connection
layer norm & residual connection :param input: [batch_size,equence_length,d_model] :param output:[batch_size,sequence_length,
model/base_model.py:59
↓ 2 callersMethodsub_layer_multi_head_attention
multi head attention as sub layer :param layer_index: index of layer number :param Q: shape should be: [batch_size,sequence_l
model/base_model.py:42
↓ 2 callersMethodsub_layer_postion_wise_feed_forward
position-wise feed forward. you can implement it as feed forward network, or two layers of CNN. :param x: shape should be:[batch_size
model/base_model.py:29
↓ 2 callersFunctiontransform_data_to_index
transform data to index using vocab and label dict. :param lines: :param vocab_word2index: :param accusation_label2index: :param
data_util_hdf5.py:141
↓ 1 callersFunction_truncate_seq_pair
Truncates a sequence pair in place to the maximum length.
run_classifier_predict_online.py:244
↓ 1 callersFunctionbuild_chunk
split list into sub lists:分块 :param lines: total thing :param chunk_num: num of chunks :return: return chunks but the last chunk may
data_util_hdf5.py:30
↓ 1 callersFunctionbuild_chunk
split list into sub lists:分块 :param lines: total thing :param chunk_num: num of chunks :return: return chunks but the last chunk may
pretrain_task.py:124
↓ 1 callersFunctioncompute_TF_FP_FN_micro
compute micro FP,FP,FN :param label_dict_accusation: a dict. {label:(TP, FP, FN)} :return:TP_micro,FP_micro,FN_micro
evaluation_matrix.py:221
↓ 1 callersFunctioncompute_confuse_matrix
compute true postive(TP), false postive(FP), false negative(FN) given target lable and predict label :param y_targetlabel_list: a list. lengt
evaluation_matrix.py:25
↓ 1 callersFunctioncompute_f1_macro_use_TFFPFN
compute f1_macro :param label_dict: {label:(TP,FP,FN)} :return: f1_macro
evaluation_matrix.py:157
↓ 1 callersFunctioncompute_f1_micro_use_TFFPFN
compute f1_micro :param label_dict: {label:(TP,FP,FN)} :return: f1_micro: a scalar
evaluation_matrix.py:147
↓ 1 callersFunctioncompute_imprisonment_score
compute imprisonment score :param target_value: a scalar :param predict_value:a scalar :return: score: a scalar
evaluation_matrix.py:112
↓ 1 callersFunctioncompute_penalty_score
compute penalty score(task 3) for a single data :param target_death: a mulit-hot list. e.g. [1,0,0,1,...] :param predict_death: [num_cla
evaluation_matrix.py:78
↓ 1 callersFunctionconvert_single_example
Converts a single `InputExample` into a single `InputFeatures`.
run_classifier_predict_online.py:154
↓ 1 callersFunctioncreate_model
Creates a classification model.
run_classifier_predict_online.py:264
↓ 1 callersFunctiondo_eval
do evaluation using validation set, and report loss, and f1 score. :param sess: :param model: :param valid: :param num_classes:
train_bert_lm.py:119
↓ 1 callersFunctiondump_cache_to_hdf5
dump cache to h5 :param cache_file: :param train: a tuple :param valid: a tuple :param test: a tuple :return: return nothing
data_util_hdf5.py:363
↓ 1 callersMethodencoder_single_layer
singel layer for encoder.each layers has two sub-layers: the first is multi-head self-attention mechanism; the second is position-wis
model/encoder.py:47
↓ 1 callersMethodget_labels
Gets the list of labels for this data set.
run_classifier_predict_online.py:102
↓ 1 callersFunctionget_lable2index
get dict of lable to index. :param lines: lines from input file :param tokenize_style: :return:
data_util_hdf5.py:290
↓ 1 callersFunctionget_mask
(batch_size,sequence_length)
model/multi_head_attention.py:149
↓ 1 callersFunctionget_mask
(batch_size,sequence_length)
model/encoder.py:95
↓ 1 callersFunctionget_target_label_short
get target label. :param y_mulitihot: [0,0,1,0,1,0,...] :return: taget_list.e.g. [3,5,100]
evaluation_matrix.py:246
↓ 1 callersMethodinference
this is for fine-tuning. main inference logic here: invoke transformer model to do inference,input is a sequence, output is also a se
model/bert_cnn_model.py:123
↓ 1 callersMethodinference
main inference logic here: invoke transformer model to do inference. input is a sequence, output is also a sequence. input representa
model/transfomer_model.py:60
↓ 1 callersMethodinference
this is for fine-tuning. main inference logic here: invoke transformer model to do inference,input is a sequence, output is also a se
model/bert_model.py:112
↓ 1 callersMethodinference_lm
this is for pre-trained language model. main inference logic here: invoke transformer model to do inference,input is a sequence, outp
model/bert_cnn_model.py:86
↓ 1 callersMethodinference_lm
this is for pre-trained language model. main inference logic here: invoke transformer model to do inference,input is a sequence, outp
model/bert_model.py:78
↓ 1 callersFunctioninit
()
model/encoder.py:69
↓ 1 callersMethodinstantiate_weights
define all weights here
model/bert_cnn_model.py:280
↓ 1 callersMethodinstantiate_weights
define all weights here
model/transfomer_model.py:109
↓ 1 callersMethodinstantiate_weights
define all weights here
model/bert_model.py:192
↓ 1 callersFunctionload_cache_from_hdf5
load cache from h5 :param cache_file: :return: train,valid, test
data_util_hdf5.py:389
↓ 1 callersFunctionload_word2vec
load pretrained word2vec in txt format :param word2vec_model_path: :return: word2vec_dict. word2vec_dict[word]=vector
data_util_hdf5.py:466
↓ 1 callersMethodloss
(self,l2_lambda=0.0001*3)
model/bert_cnn_model.py:182
↓ 1 callersMethodloss
(self,l2_lambda=0.0001*3,epislon=0.000001)
model/transfomer_model.py:92
↓ 1 callersMethodloss
(self,l2_lambda=0.0001*3)
model/bert_model.py:169
↓ 1 callersMethodloss_lm
(self,l2_lambda=0.0001*3)
model/bert_cnn_model.py:169
↓ 1 callersMethodloss_lm
(self,l2_lambda=0.0001*3)
model/bert_model.py:156
↓ 1 callersFunctionmask_language_model
generate data for perform mask language model. :parameter source_file: source file where raw data come from :parameter target_file: save
pretrain_task.py:19
↓ 1 callersFunctionoptimistic_restore
restore only those variable that exists in the model :param session: :param save_file: :return:
train_bert_fine_tuning.py:183
↓ 1 callersFunctionpad_truncate_list
pad and truncate input to maxlen based on trucating and padding strategy :param x_list:e.g. [1,10,3,5,...] :return:result_list:a new list
data_util_hdf5.py:410
↓ 1 callersFunctionpredict_online
do online prediction. each time make prediction for one instance. you can change to a batch if you want. :param line: a list. element is
run_classifier_predict_online.py:355
↓ 1 callersMethodproject_tasks
project the representation, then to do classification. :param h: [batch_size,sequence_length,d_model] :return: logits: [batch
model/transfomer_model.py:79
↓ 1 callersMethodresidual_connection
(self)
model/layer_norm_residual_conn.py:25
↓ 1 callersMethodscaled_dot_product_attention_batch
scaled dot product attention :param Q: query. shape:[batch,sequence_length,d_model] :param K_s: keys. shape:[batch,sequenc
model/multi_head_attention.py:84
↓ 1 callersFunctiontest_position_wise_feed_forward_fn
()
model/poistion_wise_feed_forward.py:86
↓ 1 callersFunctiontoken_string_as_list
(string,tokenize_style='word')
data_util_hdf5.py:338
↓ 1 callersMethodtrain
based on the loss, use SGD to update parameter
model/bert_cnn_model.py:266
↓ 1 callersMethodtrain
based on the loss, use SGD to update parameter
model/transfomer_model.py:103
↓ 1 callersMethodtrain
based on the loss, use SGD to update parameter
model/bert_model.py:186
↓ 1 callersMethodtrain_lm
based on the loss, use SGD to update parameter
model/bert_cnn_model.py:245
↓ 1 callersMethodtrain_lm
based on the loss, use SGD to update parameter
model/bert_model.py:180
↓ 1 callersFunctiontransform_multilabel_as_multihot
convert to multi-hot style :param label_list: e.g.[0,1,4], here 4 means in the 4th position it is true value(as indicate by'1') :param la
data_util_hdf5.py:195
Method__init__
Constructs a InputExample. Args: guid: Unique id for the example. text_a: string. The untokenized text of the first sequence. For sin
run_classifier_predict_online.py:59
Method__init__
(self, input_ids, input_mask, segment_ids, label_id)
run_classifier_predict_online.py:80
Method__init__
(self)
run_classifier_predict_online.py:118
Method__init__
(self)
model/config.py:3
Method__init__
init all hyperparameter with config class, define placeholder, computation graph
model/bert_cnn_model.py:18
Method__init__
:param d_model: :param d_k: :param d_v: :param sequence_length: :param h: :param batch_size:
model/base_model.py:10
Method__init__
init all hyperparameter with config class, define placeholder, computation graph
model/transfomer_model.py:18
Method__init__
(self)
model/config_transformer.py:2
Method__init__
(self,Q,K_s,V_s,d_model,d_k,d_v,sequence_length,h,typee=None,is_training=None,mask=None,dropout_rate=0.1)
model/multi_head_attention.py:18
Method__init__
(self,x,y,layer_index,residual_dropout=0.1,use_residual_conn=True)
model/layer_norm_residual_conn.py:7
Method__init__
:param d_model: :param d_k: :param d_v: :param sequence_length: :param h: :param batch_size:
model/encoder.py:13
Method__init__
init all hyperparameter with config class, define placeholder, computation graph
model/bert_model.py:18
Method__init__
:param x: shape should be:[batch,sequence_length,d_model] :param layer_index: index of layer :return: shape:[sequence_length
model/poistion_wise_feed_forward.py:19
Method_read_tsv
Reads a tab separated value file.
run_classifier_predict_online.py:107
Functioncompute_penalty_score_batch
compute penalty score(task 3) for a batch. :param target_deaths: a list. each element is a mulit-hot list :param predict_deaths: a 2-d ar
evaluation_matrix.py:59
Functioncreate_int_feature
(values)
run_classifier_predict_online.py:260
Methodget_dev_examples
Gets a collection of `InputExample`s for the dev set.
run_classifier_predict_online.py:94
Methodget_labels
See base class.
run_classifier_predict_online.py:136
Functionget_part_validation_data
(valid,num_valid=6000*20)
data_util_hdf5.py:348
Methodget_test_examples
Gets a collection of `InputExample`s for prediction.
run_classifier_predict_online.py:98
Methodget_train_examples
Gets a collection of `InputExample`s for the train set.
run_classifier_predict_online.py:90
next →1–100 of 125, ranked by callers