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. vue 绑定样式,跟点击事件的顺序会影响

    <view class="mfst-item" v-for="(item, idx) in majorArr" :key="mfsKey&quo ...

  2. Java 日期类 处理

    原始方案:SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD"); //线程不安全类,最好不要用了,替代方案: Date ...

  3. sprinboot多个子模块下 依赖包没有找到 解决方案

    最近因为在使用springboot开发项目,在开发过程中,发现自己的子模块导入通用的模块 在启动中 说找不到这个类 百度下 说我要在pom文件下 pulus 插件 那里 加上这段代码 <conf ...

  4. win10事件查看器出现10016错误的解决办法

    该错误一般会重复出现在事件查看器,严重的会导致系统卡死. 以解决下列错误为例,给出步骤: 注意记录用户(划掉的部分)及要添加的权限(本例为"本地激活"权限) 1.运行regedit ...

  5. JavaScript严格模式(use strict)

    一.什么是严格模式(strict mode) JavaScript严格模式即在严格模式下运行.严格模式下,你将不能使用未声明的变量. 注意,严格模式需要浏览器的支持:Internet explorer ...

  6. c语言学习---gets()读取字符串,以及\0,fgets()put()fputs()

    #include<stdio.h> //gets()读取字符串, 可以读取空格 int main() { char num[2] = "";//gets 也会造成内存污 ...

  7. CF79D 题解

    题解 传送门 你有 \(n\) 个灯泡,一开始都未点亮. 同时你有 \(l\) 个长度,分别为 \(a_1 \sim a_l\). 每次你可以选择一段连续的子序列,且长度为某个 \(a_i\),并将这 ...

  8. Elasticsearch集群部署和运维命令

    Elasticsearch集群部署 下载tar包 在"https://www.elastic.co/cn/downloads/elasticsearch"页面,有 past rel ...

  9. [node]把静态html挂到node接口下

    主要适用于同网段下不同设备查看同一html. 来自知乎. 需要先安装一个node,安装过程不表. 新建文件:nodeServer.js var express = require('express') ...

  10. 058_Component Bundles