栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Bert嵌入层使用BiLSTM引发+:“无类型”和“ int”的类型错误:不支持的操作数类型

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Bert嵌入层使用BiLSTM引发+:“无类型”和“ int”的类型错误:不支持的操作数类型

首先,“均值”或“第一”池的结果并不适用于所有令牌,因此您必须更改

call()
函数:

elif self.pooling == "mean":     result = self.bert(inputs=bert_inputs, signature="tokens", as_dict=True)["sequence_output" ]     pooled = result

在build_model中,更改为:

embedding_size = 768in_id = Input(shape=(max_seq_length,), name="input_ids") in_mask = Input(shape=(max_seq_length,), name="input_masks")in_segment = Input(shape=(max_seq_length,), name="segment_ids")bert_inputs = [in_id, in_mask, in_segment] bert_output = BertLayer(n_fine_tune_layers=12, pooling="mean")(bert_inputs) bert_output = Reshape((max_seq_length, embedding_size))(bert_output)bilstm = Bidirectional(LSTM(128, dropout=0.2,recurrent_dropout=0.2,return_sequences=True))(bert_output)output = Dense(output_size, activation="softmax")(bilstm)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/455877.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号