Information-Extraction-Chinese
Information-Extraction-Chinese copied to clipboard
TypeError: slice indices must be integers or None or have an __index__ method
Building prefix dict from the default dictionary ...
Loading model from cache /tmp/jieba.cache
Loading model cost 1.034 seconds.
Prefix dict has been built succesfully.
Found 4313 unique words (979180 in total)
Loading pretrained embeddings from data/vec.txt...
Found 13 unique named entity tags
20864 / 2318 / 4636 sentences in train / dev / test.
Traceback (most recent call last):
File "main.py", line 228, in
我也有一样的错误,你解决了吗?
我在Linux系统下运行,也是报出这个错误,请教怎么解决呀?
应该修改main.py中的数据类型定义 flags.DEFINE_float("batch_size", 20, "batch size") 改为 flags.DEFINE_integer("batch_size", 20, "batch size")
在发生错误的函数里,转换一下数据类型就可以了。
def sort_and_pad(self, data, batch_size): num_batch = int(math.ceil(len(data) //batch_size)) sorted_data = sorted(data, key=lambda x: len(x[0])) batch_data = list() for i in range(num_batch): i=int(i) batch_data.append(self.pad_data(sorted_data[i*batch_size : (i+1)*batch_size])) return batch_data
提供的解决方式更改后可以正确运行了,谢谢
@logye 谢谢,你说的方法很管用。