Comments (6)
问一下,您说的out of index 是predict输出成文件部分的列表越界错误吗?作者好像在代码里加了注释说他也不清楚为什么。我测试了一下,发现它有的把CLS和SEP都预测错了,导致解码失败。我觉得可以强制规定预测的第一个元素就是[CLS],最后一个元素就是[SEP]。
from name-entity-recognition.
问一下,您说的out of index 是predict输出成文件部分的列表越界错误吗?作者好像在代码里加了注释说他也不清楚为什么。我测试了一下,发现它有的把CLS和SEP都预测错了,导致解码失败。我觉得可以强制规定预测的第一个元素就是[CLS],最后一个元素就是[SEP]。
您好,您解决了吗,就是预测的时候,出现out of index。具体怎么改能指导一下吗?方便的话可以qq联系吗(642516257,微信同号)
from name-entity-recognition.
问一下,您说的out of index 是predict输出成文件部分的列表越界错误吗?作者好像在代码里加了注释说他也不清楚为什么。我测试了一下,发现它有的把CLS和SEP都预测错了,导致解码失败。我觉得可以强制规定预测的第一个元素就是[CLS],最后一个元素就是[SEP]。
您好,您解决了吗,就是预测的时候,出现out of index。具体怎么改能指导一下吗?方便的话可以qq联系吗(642516257,微信同号)
OK
from name-entity-recognition.
问一下,您说的out of index 是predict输出成文件部分的列表越界错误吗?作者好像在代码里加了注释说他也不清楚为什么。我测试了一下,发现它有的把CLS和SEP都预测错了,导致解码失败。我觉得可以强制规定预测的第一个元素就是[CLS],最后一个元素就是[SEP]。
您好,您解决了吗,就是预测的时候,出现out of index。具体怎么改能指导一下吗?方便的话可以qq联系吗(642516257,微信同号)
OK
您好,可以把方法po出来吗?具体怎么改呢?
from name-entity-recognition.
问一下,您说的out of index 是predict输出成文件部分的列表越界错误吗?作者好像在代码里加了注释说他也不清楚为什么。我测试了一下,发现它有的把CLS和SEP都预测错了,导致解码失败。我觉得可以强制规定预测的第一个元素就是[CLS],最后一个元素就是[SEP]。
您好,您解决了吗,就是预测的时候,出现out of index。具体怎么改能指导一下吗?方便的话可以qq联系吗(642516257,微信同号)
OK
您好,可以把方法po出来吗?具体怎么改呢?
# 预测样本和实体写一起写文件
with open(output_predict_file,"w",encoding="utf-8") as f:
for example, prediction in zip(predict_examples,result):
item_id=0
line=""
line_token=str(example.text_a).split(' ')
label_token=str(example.label).split(' ')
if len(line_token)!=len(label_token):
tf.logging.info(example.text_a)
tf.logging.info(example.label)
for i,id in np.ndenumerate(prediction) :
# 填充的部分舍弃
if id ==0:
continue
cur_label=id2label[id]
# CLS和SEP舍弃
if cur_label in ["[CLS]","[SEP]"]:
continue
# i[0]是prediction的索引,,第一个元素如不是[CLS],强制规定为[CLS],跳过
if i[0]==0 and cur_label!="[CLS]":
print("c",i[0],line_token)
continue
# 最后一个元素(或是填充前的最后一个元素)如不是[SEP],强制规定为[SEP],跳过
if i[0]+1>=len(prediction) or prediction[i[0]+1]==0:
if cur_label!="[SEP]":
print("s",i[0], line_token)
continue
try:
line+=line_token[item_id]+" "+label_token[item_id]+" "+ cur_label + '\n'
#line += line_token[item_id] + " " + cur_label + '\n'
except Exception as e:
tf.logging.info(e)
tf.logging.info(example.text_a)
tf.logging.info(example.label)
line=""
break
item_id+=1
f.write(line+"\n")
我这里把作者的result_to_pair函数的内容直接写在with open里面了,一些变量名字可能和作者的不一样,方法比较笨,但至少不报错了
from name-entity-recognition.
问一下,您说的out of index 是predict输出成文件部分的列表越界错误吗?作者好像在代码里加了注释说他也不清楚为什么。我测试了一下,发现它有的把CLS和SEP都预测错了,导致解码失败。我觉得可以强制规定预测的第一个元素就是[CLS],最后一个元素就是[SEP]。
您好,您解决了吗,就是预测的时候,出现out of index。具体怎么改能指导一下吗?方便的话可以qq联系吗(642516257,微信同号)
OK
您好,可以把方法po出来吗?具体怎么改呢?
# 预测样本和实体写一起写文件 with open(output_predict_file,"w",encoding="utf-8") as f: for example, prediction in zip(predict_examples,result): item_id=0 line="" line_token=str(example.text_a).split(' ') label_token=str(example.label).split(' ') if len(line_token)!=len(label_token): tf.logging.info(example.text_a) tf.logging.info(example.label) for i,id in np.ndenumerate(prediction) : # 填充的部分舍弃 if id ==0: continue cur_label=id2label[id] # CLS和SEP舍弃 if cur_label in ["[CLS]","[SEP]"]: continue # i[0]是prediction的索引,,第一个元素如不是[CLS],强制规定为[CLS],跳过 if i[0]==0 and cur_label!="[CLS]": print("c",i[0],line_token) continue # 最后一个元素(或是填充前的最后一个元素)如不是[SEP],强制规定为[SEP],跳过 if i[0]+1>=len(prediction) or prediction[i[0]+1]==0: if cur_label!="[SEP]": print("s",i[0], line_token) continue try: line+=line_token[item_id]+" "+label_token[item_id]+" "+ cur_label + '\n' #line += line_token[item_id] + " " + cur_label + '\n' except Exception as e: tf.logging.info(e) tf.logging.info(example.text_a) tf.logging.info(example.label) line="" break item_id+=1 f.write(line+"\n")
我这里把作者的result_to_pair函数的内容直接写在with open里面了,一些变量名字可能和作者的不一样,方法比较笨,但至少不报错了
感谢!!我现在就去试一下!
from name-entity-recognition.
Related Issues (20)
- 请教,生成的模型这么大吗,1.2g,参数基本没改 HOT 1
- 请教一下关于文件缺失的问题 HOT 2
- 如何取出向量值呢
- num_labels in crf_layer ?
- fyz_lattice_NER不管是跑main.py或是fyz_run_decode.sh都报错呢 HOT 2
- BERT那个为什么没有main.py,应该怎么运行呢
- 验证时eval_loss为何重新定义,以及和total_loss的区别
- 'utf-8' codec can't decode byte 0xa3 in position 0: invalid start byte HOT 1
- 运行的时候为什么老是报 name “os” is not defined 呢,都 import os了呀,请指教,谢谢
- 换成自己的数据集报错
- 请问数据集在哪里呢
- 自己的数据集
- crf层并没有起作用
- 数据集 HOT 2
- main.py文件 HOT 2
- 为什么+1 num_labels=len(label_list) + 1 HOT 1
- 为什么crf的损失值会是负数呢???
- tf_metrics.py 这里面的接口有用吗
- 请教一下,global_step/sec: 这是什么鬼,怎么不让他输出这些啊
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 name-entity-recognition.