print('Epoch[{}/{}], loss:{:.6f}'.format(epoch+1,num_epoch,loss.data[0]))

将loss.data[0] 改为loss.item()

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number的更多相关文章

  1. listview 遇到问题java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0

    开发的时候 遇到 java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 这个异常有时候会有,有时候正常 不太好捕捉 猜测 已经 ...

  2. InvalidIndexNameException[Invalid index name [2Shard], must be lowercase]

    [2016-10-11 14:16:42,191][DEBUG][action.admin.indices.create] [Feron] [2Shard] f ailed to create [2S ...

  3. vue2.5.2版本 :MAC设置应用在127.0.0.1:80端口访问; 并将127.0.0.1指向www.yours.com ;问题“ Invalid Host header”

    0.设置自己的host文件,将127.0.0.1指向自己想要访问的域名 127.0.0.1 www.yours.com 1.MAC设置应用在127.0.0.1:80端口访问: config/index ...

  4. 在数组添加元素时报错:IndexError: list index out of range

    今天第一次发随笔还有许多不足之处,欢迎评论!!! 最近在写一个成语接龙的小游戏,结果在数组添加元素时报错:IndexError: list index out of range 源码: import ...

  5. Python常见错误:IndexError: list index out of range

    用python写脚本查询字典时,在遍历字典时循环到某一项时老是报错   出现这种错误有两种情况: 第1种可能情况 list[index]index超出范围 第2种可能情况 list是空值就会出现 In ...

  6. python报错IndexError: list index out of range

    今天写个ping vpn的python脚本,报错IndexError: list index out of range 最后查看是python读取文件中出现空格 去掉空格即可

  7. pyinstaller 将.py生成.exe ----报错 “IndexError: tuple index out of range”

    pyinstaller将py打包为exe文件,用pysintaller居然报错 File "c:\anaconda3\lib\site-packages\PyInstaller\depend ...

  8. php-PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'xxx.so' in Unknown on line 0

    关于xxx.so,今天在安装php的模块时候老是报,xxx.so的问题,虽然不影响使用,但作为一名当年的程序员强迫症患者,誓死要把 他搞清楚,后面发现是删除了也没有影响,因为在安装php的时候已经将他 ...

  9. IndexError:string index out of range

    IndexError:string index out of range 出现在下标越界的情况,如 item[1],可能为空的时候下标就会越界

  10. Mac安装Mysql-python遇到的坑,被这俩报错反复摩擦:'my_config.h' file not found 和 IndexError: string index out of range

    最后Stackoverflow上面的大神解决了问题: Link brew install mysql brew unlink mysql brew install mysql-connector-c ...

随机推荐

  1. sqlserver ef 分页

    sqlserver分页常用的有两种: 1.利用row_number set statistics time on; -- 分页查询(通用型) select top pageSize * from (s ...

  2. maven加载本地的jar包

    方式1 ,通过scope = system的方式加载 <dependency> <groupId>com.sun.jna</groupId> <artifac ...

  3. JAVA仓库管理系统(附源码+调试)

    JAVA仓库管理系统--三只松鼠仓库管理系统功能描述(1)登录模块:登录信息等存储在数据库中(2)基本档案管理模块:供货商管理,销售商管理,货品档案管理,仓库管理(3)采购订货模块:用户可以通过查询条 ...

  4. 5-6:实现多窗口之异常(AttributeError: 'list' object has no attribute 'click')

    代码: #coding = utf-8 from selenium import webdriver import time ##############5-6:实现多窗口切换_start###### ...

  5. mac sourcetree required password

    coding   c85Ao 解决办法,用http拉取,使用命令行clone 每次push需要密码解决方法 sourcetree 不停的让输入密码,报 password required1.在终端(t ...

  6. 将\u8BF7字符串转换为汉字

    转发自  将\u8BF7\u9009\u62E9 字符串转为汉字的代码_javascript技巧_脚本之家 链接:https://www.jb51.net/article/25187.htm

  7. 用Python把PDF文件转换成Word文档

    首先,下载所需要的库 1 :pdfminer   安装库命令: pip install pdfminer3k 2:  docx     安装库命令: pip install python_docx 开 ...

  8. mysql两表关联

    mysql两表关联 是按照范围关联表 select * from ((select u.id,u.name,u.sex,s.street_name,u.street_code,u.birthday f ...

  9. Python通过解压ofd文件获取发票信息

    实际上ofd.docx.xlsx等文件就是一个压缩文件,是可以被解压处理的.所以我们把一个ofd格式的发票文件解压后就可以看到它的目录,如下: 再用谷歌或者IE打开里面的xml属性的文件,就可以看到发 ...

  10. jenkins +docker+python接口自动化之jenkins拉取gitee上的代码(四)

    1.背景 1.经过我们前面几轮的安装测试,我们已经安装了jenkins容器,python3,以及运行我们python代码所需要的第三方库在requirements.txt文件下统一安装. 2.需求 我 ...