()
return model
BERT+CRF模型
    :return:
BERT+CRF模型
    :return:
BERT + CRF模型 : return :
def bert_model():
    '''
    BERT+CRF模型
    :return:
    '''
    bert_path = 'bert_model/'
    config_path = bert_path+'bert_config.json'
    checkpoint_path = bert_path+'bert_model.ckpt'
    bert_model = load_trained_model_from_checkpoint(config_path, checkpoint_path,trainable=True,seq_len=52)
    x = bert_model.output
    x = TimeDistributed(Dropout(arg.dropout))(x)
    crf = CRF(units=4, learn_mode='join',test_mode='viterbi', sparse_target=True)
    x = crf(x)
    model = Model(bert_model.inputs, x)
    model.compile(optimizer=adam(1e-5), loss=crf.loss_function, metrics=[crf.accuracy])
    return model
def bert_model ( ) : bert_path = 'bert_model/' config_path = bert_path + 'bert_config.json' checkpoint_path = bert_path + 'bert_model.ckpt' bert_model = load_trained_model_from_checkpoint ( config_path , checkpoint_path , trainable = True , seq_len = 52 ) x = bert_model . output x = TimeDistributed ( Dropout ( arg . dropout ) ) ( x ) crf = CRF ( units = 4 , learn_mode = 'join' , test_mode = 'viterbi' , sparse_target = True ) x = crf ( x ) model = Model ( bert_model . inputs , x ) model . compile ( optimizer = adam ( 1e-5 ) , loss = crf . loss_function , metrics = [ crf . accuracy ] ) return model