IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

将datra[0]换成item() 即可

原文地址:https://www.cnblogs.com/blogwangwang/p/11985750.html

时间: 2024-08-30 08:00:17

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

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

开发的时候 遇到 java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 这个异常有时候会有,有时候正常 不太好捕捉 猜测 已经把数据给了list,然后让主线程去显示:接着后台继续获取数据.那也许有可能主线程还是没刷新完,后台又把新数据给过来了 所以 猜测 是刷新头部出现的问题 也就是 news.clear(); news.addAll(0, refreshNewData); newsAdapter.notifyDataSe

if(str(saved_path).split('.')[1].lower() != 'gif'): IndexError: list index out of range ERROR basehttp 124 "POST /ckeditor/upload/ HTTP/1.1" 500 96995

用python写Django项目的时候 用了CKEditor富文本编辑器,编辑文本,上传图片的时候,当我点击上传到服务器,一开始网页 页面弹出 '不正确的服务器响应',我上网查,看到说版本的原因,我又去降pip install django-ckeditor==4.5.3 然后又出来其他问题 TypeError: build attrs() got an unexpected keyword argument 'name'TypeError:build attrs()得到了一个意想不到的关键字参

elasticsearch报InvalidIndexNameException[Invalid index name [demo_indexX1], must be lowercase错误

[demo_indexX1] InvalidIndexNameException[Invalid index name [demo_indexX1], must be lowercase] at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.validateIndexName(MetaDataCreateIndexService.java:151) at org.elasticsearch.cluster.metada

"kewastUnPackStats(): bad magic 1 (0xXXXXXXXXX, 0)" in Alert Logfile After Upgrading to 11.2.0.1 (文档

 "kewastUnPackStats(): bad magic 1 (0xXXXXXXXXX, 0)" in Alert Logfile After Upgrading to 11.2.0.1 (文档 ID 1227524.1) 转到底部 In this Document Symptoms   Cause   Solution   References APPLIES TO: Oracle Database - Enterprise Edition - Version 9.2.0

Oracle11.2.0.4 windows32+64bit path补丁21+11.2.0.4.160419 p22064588 p22839608

2016年6月3日最新补丁-Oracle11.2.0.4 for windows32+64bit,p22064588 patch11.2.0.4.21,p22839608 11.2.0.4.160419补丁包 版本:Oracle11.2.0.4.21 p22064588 补丁 百度云盘:链接:http://pan.baidu.com/s/1pLRCNjH 密码:aa0q 名称:64BIT:p22064588_112040_MSWIN-x86-64.zip名称:32BIT:p22064588_11

编译Qt5.0连接MySql5.5数据库的驱动(5.0版本的编译,我记得5.2开始自带了)

第一步 1.准备好Mysql数据库安装文件,Qt5.0完整的离线安装包,以及Qt5.0的完整的源代码.安装好程序,假设Mysql的安装路径为:C:\MySQL5.5,Qt5.0的安装路径:C:\Qt\Qt5.0.0-rc2\5.0.0-rc2,而Qt5.0的解压路径为:C:\Qt\qt-5.0.1-src. 注意事项:(1)安装mysql数据库的时候,网上很多教程说要选择自定义安装,并把lib和include这个选项选上.其实这个并不重要.因为我机器上很久前装mysql时选的是typical安装

输入字符串(由0,1组成),编程计算其中连续0,1出现的最大次数

代码如下: #include<iostream> #include<string> using namespace std; int main() { string s; cin>>s; //s有1,0组成 int len=s.size(); int max1=0,max0=0; int tem0=0,tem1=0; int i=0; while(i<len) { if(s[i]=='0') { tem0++; i++; if(s[i]=='1'||i==len)

IIS6 2.0 4.0 冲突解决 &#39;c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\xxx&#39; -- &#39;Access is denied. &#39;

今天在阿里云虚拟机上部署新站点后出现下面的错误: Compiler Error Message: CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\xx' -- 'Access is denied. ' 找遍了网上的资料最后总结为以下几步:: Cleaned the "C:\Windows\Microsoft.NE

软考 -&gt; 子网172.6.32.0/20被划分成子网172.6.32.0/26

为了复习一下计算机知识,响应公司号召参加软考,看书过程中发现好多知识都忘却了... 比如,下面这道题目,我是真不会啊. 如果子网172.6.32.0/20被划分成子网172.6.32.0/26,则下面的结论中正确的是() A. 被划分成62个子网 B. 每个子网有64个主机地址 C. 被划分成32个子网 D. 每个子网有62个主机地址 172.6.32.0/20中的20表示网络号的位数. 172.6.32.0 = (10101100,00000110,00100000,00000000)2 而1