text-classification-demos
text-classification-demos copied to clipboard
fasttext cnn model TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Ubuntu16.04+cuda 9.0+tensorflow-gpu 1.11.0
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
========================================================
2019-02-25 19:54:15.464610: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-02-25 19:54:15.464678: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0
2019-02-25 19:54:15.464686: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N
2019-02-25 19:54:15.465047: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 14871 MB memory) -> physical GPU (device: 0, name: Tesla V100-PCIE-16GB, pci bus id: 0000:03:00.0, compute capability: 7.0)
Epoch: 1
Traceback (most recent call last):
File "/home/kelvin/deeplearning/text-classification-demos/fasttext_model.py", line 209, in
Process finished with exit code 1
I also got this problem. How to solve this?
I also got this problem on tensorflow-gpu 1.12.0
Same problem ...
I wang to know how to solve this?
Same problem ...
I also got this problem. How to solve this? 因为编码问题,utils/cnews_loader.py python2中不能直接支持中文编码 所以必须要用utf-8格式,所以用codes将文件读成以及写入都搞成utf-8格式 例如categories = ['体育', '财经', '房产', '家居', '教育', '科技', '时尚', '时政', '游戏', '娱乐'] categories = [categorie.decode('utf-8') for categorie in categories] 已解决
Hi, all I have found the reason for this issue. The problem lies in the code 105-113 in the cnews_loader.py During the preprocessing, the word is changed into id. However, the <UNK> is not int the cnews_vocab.txt, which leads to the None because of the 'get' operator.
这个issue的问题是由于在预处理中将字转换成id的过程中。 当出现非字典内的字时,会使用<UNK>来替代,然而下拉的代码中cnews_vocab.txt并没有<UNK>对应的编号id,所以才会出现None类型的数据,导致data_id不是int类型,而是object类型,进而导致训练失败问题。
解决办法:在cnews_vocab.txt中添加 <UNK> 1即可,当然要删掉一个字,比如最后一个字。