Git Product home page Git Product logo

Comments (6)

taishan1994 avatar taishan1994 commented on June 12, 2024

作者您好 在用高版本torch运行您的代码时出现了和楼上一样的错误 在第89轮训练报错 ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part. image 更换低版本后 并修改这句代码后attention_masks = torch.from_numpy(np.array(encode_dict['attention_mask'])).long().unsqueeze(0).to(device) 还是会出现 image 大佬可以指点一下吗 谢谢!

你predict里面代码是这样的吗:

try:
    attention_masks = torch.from_numpy(np.array(encode_dict['attention_mask'], dtype=np.uint8)).unsqueeze(0).to(device)
except Exception as e:
    attention_masks = torch.from_numpy(np.array(encode_dict['attention_mask'])).long().unsqueeze(0).to(device)

from pytorch_bert_bilstm_crf_ner.

yyQUQ avatar yyQUQ commented on June 12, 2024

作者您好,问题同上,更改你刚才给出的代码依然报错,请问哪里出问题了,烦请解答
24260a86b839a96d5e05c09055c0f96

from pytorch_bert_bilstm_crf_ner.

taishan1994 avatar taishan1994 commented on June 12, 2024

作者您好,问题同上,更改你刚才给出的代码依然报错,请问哪里出问题了,烦请解答 24260a86b839a96d5e05c09055c0f96

方便发下你的torch和transformers版本么

from pytorch_bert_bilstm_crf_ner.

taishan1994 avatar taishan1994 commented on June 12, 2024

作者您好,问题同上,更改你刚才给出的代码依然报错,请问哪里出问题了,烦请解答 24260a86b839a96d5e05c09055c0f96

改下这个试试:

token_ids = torch.from_numpy(np.array(encode_dict['input_ids'])).long().unsqueeze(0).to(device)

from pytorch_bert_bilstm_crf_ner.

yyQUQ avatar yyQUQ commented on June 12, 2024

谢谢大佬,好了!

from pytorch_bert_bilstm_crf_ner.

yyQUQ avatar yyQUQ commented on June 12, 2024

from pytorch_bert_bilstm_crf_ner.

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.