此篇博客内容为短暂存留记录(项目使用过程还未记录),后续将会更新完整学习流程。。

1.根据官网上的链接安装有两种方式:

(1)pip直接安装

  1. pip install transformers # 安装时间长,出现Timeout Error的可能性大,个人不建议

(2)GIthub下载源包

  1. git clone https://github.com/huggingface/transformers # 下载时间长一点(网盘自取)
  2. cd transformers
  3. pip install .

transformers下载:

链接:https://pan.baidu.com/s/1Z9Pwdzwa671JNmQPzYNlUQ
提取码:dsei

2.安装之后需要进行测试

  1. python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('I hate you'))" # 官网给的测试代码,运行出来结果就是安装成功了

安装成功:

 报错

一开始,测试代码运行后出现了报错,如下:

报错内容如下:

AttributeError: 'Tensor' object has no attribute 'ndim'

ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length.

明明操作都按照官网上的来,最后百思不得其解自己改了从官网下载下来的源码,这里报错的文件是指向了D:\Anaconda3\Lib\site-packages\transformers下的tokenization_utils_base.py文件,找到具体报错那一行的代码,如下:

获取tensor的维度信息dims,正确代码应该是len(list(tensor.size()))。

再次执行测试代码,成功出来结果!

transformers加载后缓存文件是:

安装Transformers与ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length.报错的更多相关文章

  1. (转)Genymotion安装virtual device的“unable to create virtual device, Server returned Http status code 0”的解决方法

    网络原因无法下载virtual device,status 为0表示服务器没有响应.FQ下载吧,有VPN的小伙伴推荐这种. 或者直接手动下载ova虚拟机文件,然后将虚拟机文件导入到virtualbox ...

  2. windows 安装docker报错:Error checking TLS connection: ssh command error: command : ip addr show

    今天安装docker部署的时候总是再报这个错误. 报错的原因是初始化的时候出错了. 在docker 安装目录下有一个文件,如下图所示 将它复制到你电脑用户名目录下生成.docker 的文件夹中,如下图 ...

  3. SharePoint 2013 安装.NET Framework 3.5 报错

    环境描述 操作系统:Windows Server 2012 R2 Datacenter版本 安装报错 中途接手安装SharePoint Server 2013 with sp1,配置向导报错如下: A ...

  4. webdriver驱动火狐浏览器报错:Unable to find a matching set of capabilities

    raise exception_class(message, screen, stacktrace)selenium.common.exceptions.SessionNotCreatedExcept ...

  5. 安装Windows Server 2012 R2提示"unable to create a new system partition or locate an existing system partition"解决方法

    重新安装Windows Server 2012 R2,把原来SSD分区全部格式化重建,用U盘启动安装时提示如下: "Setup was unable to create a new syst ...

  6. python2用pip进行安装时报错Fatal error in launcher: Unable to create process using '"'

    win7下python3和python2共存环境 用pip安装一个包执行pip2 install xxx的时候报错Fatal error in launcher: Unable to create p ...

  7. pip安装lxml报错 Fatal error in launcher: Unable to create process using '"c:\users\administrator\appdata\local\programs\python\python36\python.exe" "C:\Users\Administrator\AppData\L

    pip install lxml 安装报错 E:\apollo\spider_code>Fatal error in launcher: Unable to create process usi ...

  8. 安装Python,输入pip命令报错———pip Fatal error in launcher: Unable to create process using

    今天把Python的安装位置也从C盘剪切到了D盘, 然后修改了Path环境变量中对应的盘符:D:\Python27\;D:\Python27\Scripts; 不管是在哪个目录,Python可以执行了 ...

  9. Source Insight 4.0安装后首次打开报错Unable to open or create

    错误提示大概如下: Unable to open or create ....我的文档/source insght4.0/xxx.sidb. 这个错误提示就是找不到这个文件,原因是应为有中文路径,那么 ...

随机推荐

  1. MySQL-LSN

    查看lsn:   show engine innodb status Log sequence number 2687274848548    Log flushed up to 2687274848 ...

  2. python之数据库编程

    python之数据库编程 sqlite 1.前期准备工作 导入模块: import sqlite3 连接数据库 conn = sqlite3.connect("test.db") ...

  3. Django+Ansible构建任务中心思路

    Ansible作为老牌的自动化运维工具,由Python开发,应用广泛,但其默认只提供了命令行下的使用方式,好在提供有完善的API支持二次开发,可以很方便的集成到我们的自动化运维系统中 最近一个朋友跳槽 ...

  4. MyBatis-Plus 代码生成器模板

    MyBatis-Plus 代码生成器模板 maven 依赖 <!--Mysql--> <dependency> <groupId>mysql</groupId ...

  5. JMeter中使用交替控制器设置循环次数后都执行一次?

    JMeter在线程组设置循环3次,执行后只执行了一次就停止执行了 排查原因:线程组下添加了一些请求信息(HTTP Cache Manager.HTTP Cookie Manager.HTTP Requ ...

  6. Selenium系列(十七) - Web UI 自动化基础实战(4)

    如果你还想从头学起Selenium,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1680176.html 其次,如果你不懂前端基础知识, ...

  7. 百度云网速慢?普通VIP也限速?用户激励措施太套路?Pandownload被举报?这些统统没关系,我们自己搭建一个私人云盘服务器

    前言 前几天醒来后,照例耍手机看新闻.在疫情如此严重的档口,一则小小的新闻引起了我内心小小的波动:Pandownload作者被举报了....心里第一件事就是可惜了我盘上的那N多个T的小电影了,&quo ...

  8. 枚举类enum

    一.枚举类 package com.xxx.xf.common.enums; import com.xxx.xf.workday.contant.HolidayContant; /** * @Auth ...

  9. 回收Windows 10恢复分区之后的磁盘空间

    我电脑上安装了Windows 10和Linux双系统,现在将Linux删除之后,准备将其磁盘空间并入到Windows 10的C盘中,但是发现C盘跟Linux空间之间还隔了一个Windows的恢复分区, ...

  10. expression select表达式动态构建

    参考: http://blog.csdn.net/tastelife/article/details/7340205 http://blog.csdn.net/sweety820/article/de ...