当前位置: 首页 > news >正文

防水网站建设万能bt搜索引擎网站

防水网站建设,万能bt搜索引擎网站,长春seo招聘,电子商务网站网络推广方式前言: 昨天我们讲述了怎么利用emotion数据集进行deberta-v3-large大模型的微调,那今天我们就来输入一些数据来测试一下,看看模型的准确率,为了方便起见,我直接用测试集的前十条数据 代码: from transfor…

前言:

昨天我们讲述了怎么利用emotion数据集进行deberta-v3-large大模型的微调,那今天我们就来输入一些数据来测试一下,看看模型的准确率,为了方便起见,我直接用测试集的前十条数据

代码:

from transformers import AutoModelForSequenceClassification,AutoTokenizer
import torch
import numpytokenizer = AutoTokenizer.from_pretrained("deberta-v3-large")
model = AutoModelForSequenceClassification.from_pretrained("result/checkpoint-500",num_labels=6)raw_inputs = ["im feeling rather rotten so im not very ambitious right now","im updating my blog because i feel shitty","i never make her separate from me because i don t ever want her to feel like i m ashamed with her","i left with my bouquet of red and yellow tulips under my arm feeling slightly more optimistic than when i arrived","i was feeling a little vain when i did this one","i cant walk into a shop anywhere where i do not feel uncomfortable","i felt anger when at the end of a telephone call","i explain why i clung to a relationship with a boy who was in many ways immature and uncommitted despite the excitement i should have been feeling for g
etting accepted into the masters program at the university of virginia","i like to have the same breathless feeling as a reader eager to see what will happen next","i jest i feel grumpy tired and pre menstrual which i probably am but then again its only been a week and im about as fit as a walrus on vacation for thesummer"
]
inputs = tokenizer(raw_inputs, padding=True, truncation=True, return_tensors="pt")
outputs = model(**inputs)
print(outputs.logits.argmax(-1).numpy())output_tensor = torch.softmax(outputs.logits, dim=1)numpy.set_printoptions(suppress=True, precision=15)
print(output_tensor.detach().numpy())

标注结果:

[0 0 0 1 0 4 3 1 1 3]

测试结果:

[0 0 0 1 0 4 4 2 1 3]
[[0.99185866    0.0011510316  0.00038844926 0.0026896652  0.00296234010.00094986777][0.9918577     0.0011512033  0.00038886679 0.0026923663  0.00295853150.000951257  ][0.99185807    0.0011446937  0.00038163515 0.0026456509  0.00303544850.00093440723][0.00041773843 0.9972398     0.0014854104  0.0002909223  0.000362315240.00020376328][0.99185014    0.0011451623  0.00038086114 0.0026396883  0.00305240350.00093187904][0.015044774   0.0025362356  0.00041989447 0.015223678   0.950097140.016678285  ][0.11319714    0.030935207   0.007336047   0.3035547     0.475454330.069522515  ][0.0011094044  0.18334262    0.8081213     0.0011003793  0.00072979650.005596481  ][0.0004444314  0.9972433     0.0014491597  0.00028465112 0.000374119760.00020446534][0.00241266    0.00079152075 0.00092184055 0.9924028     0.00241092480.0010602956 ]]

结果对比:

除了第七、第八条数据错误外,其他的八条数据都是正确的

代码解释:

1、raw_inputs:用户输入的数据,这个地方你可以使用一个while循环,然后使用input来与用户进行交互,需要注意的是这个必须是一个数组,哪怕用户只输入了一句文本。

2、return_tensors="pt":表示tokenizer返回的是PyTorch格式的数据

3、argmax(-1):将logits属性中的浮点数张量沿着最后一个轴(即-1轴)进行argmax操作,从而找到该张量中最大值所对应的标签编号。

4、softmax(outputs.logits, dim=1):dim指沿着哪个维度计算softmax,通常指定为1,表示对每一行进行softmax操作。如果不指定,则默认在最后一维计算softmax。

5、numpy.set_printoptions(suppress=True, precision=15):使用 numpy.set_printoptions() 函数来设置打印选项,从而调整打印输出格式。其中,suppress 选项可以关闭科学计数法,precision 选项可以设置打印精度。

http://www.zhongyajixie.com/news/37265.html

相关文章:

  • 承包酒席可以做网站吗郑州网站网页设计
  • wordpress登陆地址csdnseo网站设计
  • 做淘宝的网站的多少钱怎么开网店
  • 网站网页区别是什么意思网络项目资源网
  • int域名网站有哪些福州百度推广优化排名
  • 海珠做网站公司杭州百度公司在哪里
  • 网站空间服务多少钱软文世界平台
  • 哪些网站做外链培训机构优化
  • wordpress安装音乐插件甘肃搜索引擎网络优化
  • 怎样做网站的优化网络营销的主要方法
  • h5技术做网站seo做的比较好的公司
  • 简易购物网站html代码百度app下载并安装最新版
  • 一级做爰网站百度首页精简版
  • 澄迈住房和城乡建设局网站懂得网站推广
  • 网站由什么构成网站流量统计平台
  • 优化网站 主题成功的软文营销案例
  • 网站建设费用构成阿里云网站搭建
  • 公司在选择网站时应考虑什么问题商丘seo公司
  • 做网站需要花钱吗关键词优化技巧
  • 上海网站建设广告语河南怎样做网站推广
  • 金华安全网站建设怎么收费广州新一期lpr
  • 幼儿园网站怎么做的seop
  • 做网站好看的旅行背景图片广州网站推广联盟
  • 做维修广告效最好是哪个网站吗对网络营销的认识有哪些
  • 做网站主流技术市场调研报告word模板
  • 全椒有做网站的吗广州seo外包多少钱
  • 规范机关单位网站建设neotv
  • 网站建设 微信营销网站在线优化工具
  • 做网站哪种编程语言最好下载app
  • 营销型网站建设公司提供网站建设网络优化公司有哪些