GithubHelp home page GithubHelp logo

Comments (17)

649453932 avatar 649453932 commented on June 10, 2024

这个是词表,看一下utils.py文件中36至40行,若词表不存在,就会通过build_vocab函数自动创建,我这里保存成pkl格式了。

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

没有词表时,build_vocab函数不创建,报错
Traceback (most recent call last):
File "utils.py", line 134, in
word_to_id = pkl.load(open(vocab_dir, 'rb'))
FileNotFoundError: [Errno 2] No such file or directory: './THUCNews/data/vocab.pkl'

from chinese-text-classification-pytorch.

649453932 avatar 649453932 commented on June 10, 2024

提取预训练词向量我忘记加构建词表这个逻辑了...,现在改好了,新的utils.py文件已经上传了

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

我没有sgns.sogou.char的字符列表,可以随机生成,不使用吗?
Traceback (most recent call last):
File "utils.py", line 145, in
f = open(pretrain_dir, "r", encoding='UTF-8')
FileNotFoundError: [Errno 2] No such file or directory: './THUCNews/data/sgns.sogou.char'

from chinese-text-classification-pytorch.

649453932 avatar 649453932 commented on June 10, 2024

python run.py --model TextCNN --embedding random

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

哦,对哦,我忘了,你的代码是可以的,谢谢

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

我能再请教个问题吗?这种错误要怎么改
Traceback (most recent call last):
File "run.py", line 42, in
dev_iter = build_iterator(dev_data, config)
File "/home/zgy/wll/Tibetan-Text-Classification-Pytorch/utils.py", line 120, in build_iterator
iter = DatasetIterater(dataset, config.batch_size, config.device)
File "/home/zgy/wll/Tibetan-Text-Classification-Pytorch/utils.py", line 80, in init
if len(batches) % self.n_batches != 0:
ZeroDivisionError: integer division or modulo by zero

from chinese-text-classification-pytorch.

649453932 avatar 649453932 commented on June 10, 2024

你的n_batches等于0了,检查一下你的数据量和batch_size的大小

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

开心,弄好了

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

最后再打扰您一下下,为什么运行同样的utils.py,我CNN模型的时候成功了,跑RNN等模型的时候就报以下错误
Traceback (most recent call last):
File "run.py", line 40, in
vocab, train_data, dev_data, test_data = build_dataset(config, args.word)
File "/home/zgy/wll/Tibetan-Text-Classification-Pytorch/utils.py", line 37, in build_dataset
vocab = pkl.load(open(config.vocab_path, 'rb'))
_pickle.UnpicklingError: invalid load key, '\xff'.

from chinese-text-classification-pytorch.

649453932 avatar 649453932 commented on June 10, 2024

这个是在调用模型之前执行的,是不是词表文件更改了,你把词表删了再重新生成一次试试?

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

我删除了,然后重新生成,还是报同样的错误

from chinese-text-classification-pytorch.

649453932 avatar 649453932 commented on June 10, 2024

那我也不知道了,我这边没有这种问题。。。

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

好吧,我再弄弄吧

from chinese-text-classification-pytorch.

649453932 avatar 649453932 commented on June 10, 2024

如果实在找不到问题所在,你可以把词表存成txt格式,直接open就行了

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

好的呀,我能加你个联系方式吗?在这聊,好像不太好

from chinese-text-classification-pytorch.

lili1234567890 avatar lili1234567890 commented on June 10, 2024

15682766780,电话微信同一个,或者QQ1:1335502737

from chinese-text-classification-pytorch.

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.