Giter VIP home page Giter VIP logo

Comments (5)

xesgue avatar xesgue commented on May 26, 2024 3

似乎找到问题了,是word_emb_elmo.py中的max_len和emb.shape[1]数值的问题,为什么我用您test的文档或者其他文档,都是显示emb.shape[1]比max_len要多1,所以按照代码逻辑相减成了负数,因此我在前面加上了abs,改成了[np.pad(emb, pad_width=((0,0),(0,abs(max_len-emb.shape[1])),(0,0)) , mode='constant') for emb in elmo_embedding],运行成功了,您知道是为什么会导致这个情况吗?

from sifrank_zh.

sunyilgdx avatar sunyilgdx commented on May 26, 2024

可否贴出报的错 @xesgue

from sifrank_zh.

xesgue avatar xesgue commented on May 26, 2024

Traceback (most recent call last):
File "D:/algo/SIFRank_zh-master/embeddings/word_emb_elmo.py", line 38, in
embs = elmo.get_tokenized_words_embeddings(sents)
File "D:/algo/SIFRank_zh-master/embeddings/word_emb_elmo.py", line 29, in get_tokenized_words_embeddings
elmo_embedding = [np.pad(emb, pad_width=((0,0),(0,max_len-emb.shape[1]),(0,0)) , mode='constant') for emb in elmo_embedding]
File "D:/algo/SIFRank_zh-master/embeddings/word_emb_elmo.py", line 29, in
elmo_embedding = [np.pad(emb, pad_width=((0,0),(0,max_len-emb.shape[1]),(0,0)) , mode='constant') for emb in elmo_embedding]
File "<array_function internals>", line 6, in pad
File "D:\Anaconda\envs\baidu\lib\site-packages\numpy\lib\arraypad.py", line 748, in pad
pad_width = _as_pairs(pad_width, array.ndim, as_index=True)
File "D:\Anaconda\envs\baidu\lib\site-packages\numpy\lib\arraypad.py", line 519, in _as_pairs
raise ValueError("index can't contain negative values")
ValueError: index can't contain negative values
和之前别人报错信息一样的@sunyilgdx

from sifrank_zh.

sunyilgdx avatar sunyilgdx commented on May 26, 2024

我也不太清楚呢,我们这边是正常运行的,很多其他同学通过更改elmo.py文件也可以正常运行

from sifrank_zh.

lmx666-gif avatar lmx666-gif commented on May 26, 2024

似乎找到问题了,是word_emb_elmo.py中的max_len和emb.shape[1]数值的问题,为什么我用您test的文档或者其他文档,都是显示emb.shape[1]比max_len要多1,所以按照代码逻辑相减成了负数,因此我在前面加上了abs,改成了[np.pad(emb, pad_width=((0,0),(0,abs(max_len-emb.shape[1])),(0,0)) , mode='constant') for emb in elmo_embedding],运行成功了,您知道是为什么会导致这个情况吗?

您好,我用您的方法之后有出现了新的问题,ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (3,2) and requested shape (2,2)
您知道是为什么吗

from sifrank_zh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.