行秩列秩矩阵的秩
2021-03-01 19:29
采纳率: 100%
浏览 562

使用kashgari实现BERT+Bilstm命名实体识别,在保存模型时报错!!!求助!!!

 以下是我的代码,

import tensorflow as tf
import time
import jieba as jb
import random
import kashgari
import sys,io
from kashgari.corpus import ChineseDailyNerCorpus
from kashgari.tasks.labeling import BiLSTM_Model
from kashgari.embeddings import BertEmbedding

sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8') # Change default encoding to utf8

start = time.process_time()
train_x,train_y = ChineseDailyNerCorpus.load_data('train')
test_x, test_y = ChineseDailyNerCorpus.load_data('test')
valid_x, valid_y = ChineseDailyNerCorpus.load_data('valid')

embedding = BertEmbedding('chinese_L-12_H-768_A-12')
model = BiLSTM_Model(embedding,sequence_length=100)
model.fit(train_x,train_y,valid_x,valid_y,epochs=1)

model.save('model_learn2/bilstm_ner')

end = time.process_time()
step = end - start
print("总共耗时:%0.3f 秒,相当于 %0.3f 分钟" % (step,step / 60))

结果报出这样的错误

我的TensorFlow版本是2.1.0;kashgari版本是2.0.1;BERT, Chinese 中文模型使用的是Google Cloud的BERT-base, Chinese

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

5条回答 默认 最新

相关推荐 更多相似问题