yongzhuo / Keras-TextClassification

中文长文本分类、短句子分类、多标签分类、两句子相似度(Chinese Text Classification of Keras NLP, multi-label classify, or sentence classify, long or short),字词句向量嵌入层(embeddings)和网络层(graph)构建基类,FastText,TextCNN,CharCNN,TextRNN, RCNN, DCNN, DPCNN, VDCNN, CRNN, Bert, Xlnet, Albert, Attention, DeepMoji, HAN, 胶囊网络-CapsuleNet, Transformer-encode, Seq2seq, SWEM, LEAM, TextGCN

Home Page:https://blog.csdn.net/rensihui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

文本相似度计算的时候报AttributeError: 'tuple' object has no attribute 'layer'

Fino2020 opened this issue · comments

您好,在使用test\sentence_similarity\train.py运行的时候,报错:
AttributeError: 'tuple' object has no attribute 'layer',按照之前的一些issue,我更改了tf的版本为1.14.0,Keras版本为2.2.4,keras-bert的版本为0.41.0;并且这套环境在运行文本分类器的时候完全正常,没有产生报错。请问是什么问题呢

初步排查好像是BERT的问题,在使用其他词嵌方法的时候(例如random、word2vec)报的不是这个错;报的是:TypeError: cannot unpack non-iterable NoneType object。同时我使用分类器里的Bert分类器也会报AttributeError: 'tuple' object has no attribute 'layer'这个错。

好吧是keras-bert==0.41.0 与 keras-xlnet==0.16.0不能共存的原因,两个都删了重新装keras-bert就好了,是我看issue不够仔细。