Comments (17)
这个是词表,看一下utils.py文件中36至40行,若词表不存在,就会通过build_vocab函数自动创建,我这里保存成pkl格式了。
from chinese-text-classification-pytorch.
没有词表时,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.
提取预训练词向量我忘记加构建词表这个逻辑了...,现在改好了,新的utils.py文件已经上传了
from chinese-text-classification-pytorch.
我没有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.
python run.py --model TextCNN --embedding random
from chinese-text-classification-pytorch.
哦,对哦,我忘了,你的代码是可以的,谢谢
from chinese-text-classification-pytorch.
我能再请教个问题吗?这种错误要怎么改
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.
你的n_batches等于0了,检查一下你的数据量和batch_size的大小
from chinese-text-classification-pytorch.
开心,弄好了
from chinese-text-classification-pytorch.
最后再打扰您一下下,为什么运行同样的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.
这个是在调用模型之前执行的,是不是词表文件更改了,你把词表删了再重新生成一次试试?
from chinese-text-classification-pytorch.
我删除了,然后重新生成,还是报同样的错误
from chinese-text-classification-pytorch.
那我也不知道了,我这边没有这种问题。。。
from chinese-text-classification-pytorch.
好吧,我再弄弄吧
from chinese-text-classification-pytorch.
如果实在找不到问题所在,你可以把词表存成txt格式,直接open就行了
from chinese-text-classification-pytorch.
好的呀,我能加你个联系方式吗?在这聊,好像不太好
from chinese-text-classification-pytorch.
15682766780,电话微信同一个,或者QQ1:1335502737
from chinese-text-classification-pytorch.
Related Issues (20)
- Text_RCNN文本分类效果
- 使用自己的数据集出现问题 HOT 1
- FastText的n_gram_vocab HOT 1
- 一个文本要是有多个标签要怎么用这个模型呢 HOT 3
- 用模型进行预测,该怎么实现呢 HOT 2
- 如果想改成英文数据,都需要修改什么呢
- transformer HOT 2
- 可以写一个单条预测的接口嘛?
- RuntimeError: GET was unable to find an engine to execute this computation
- 是否有文本长度限制 HOT 1
- Bi-LSTM问题
- 是否是没有进行分词?
- 选择题如何定制输入
- 词向量训练问题
- [BUG] TextCNN训练速度很慢
- 请问为何TextCNN的一个iter为什么要十几分钟,而TextRNN就很快,一个epoch不到一分钟? HOT 2
- 网络结构中Model加载预训练词向量的疑问
- 这个仓是不是没有维护了呀?
- AttributeError: 'Config' object has no attribute 'n_gram_vocab' HOT 1
- 模型预测类 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chinese-text-classification-pytorch.