复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

复现ACL2020TextING时的错误

ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

直接说结果,自行核对,glove.6B.300d.txt的文件可能在我复制粘贴时弄坏了,后面少了一大截,重新下载吧!

复制到浏览器即可下载http://nlp.stanford.edu/data/glove.6B.zip

 

排坑过程,给自己看的,以后排坑可以想想try except

参考https://blog.csdn.net/qq_38766844/article/details/98232872

他的代码

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

 

 

 

错的地方就加一个try except

我的代码

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

 

 

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

 复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

 

 

 

?总不能单独改,一个个删吧

 

继续找错,在build_graph.py里未登陆词oov是随机的,在glove里的就直接用,坏了坏了,一个是ndarray一个是list???黑人问号

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

 

 

 build_graph.py中全部改成ndarray

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

 

 

 复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

下图同上图,更直观放在一起,他们就是不一样呵呵

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

 

 

 

破案啦破案啦

本来想着会不会是维度的问题,粗暴点直接np.reshape(word_embeddings[k], 300),这下好了,一shape就发现有一个维度是142的不是300,把那个词也给打出来,是products!!,打开glove的文件直接ctrl+F搜products,不看不知道一看吓一跳,居然在最后一行,而且确实不满300维,好家伙,下载船新版本的glove吧。复制到浏览器即可下载http://nlp.stanford.edu/data/glove.6B.zip,不大,压缩包也就822M,300维解出来也就989M!

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

 

复现ACL2020TextING时报错ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (1,2)

上一篇:539 · 移动零


下一篇:application.properties配置文件