请问如下代码为什么报错:TypeError: Fetch argument None has invalid type <class 'NoneType'>
import tensorflow as tf

w1 = tf.Variable([[1, 2]])
w2 = tf.Variable([[3, 4]])

y = tf.matmul(w1, [[9], [10]])

grads = tf.gradients(y, [w1])

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    gradval = sess.run(grads)
    print(gradval)

2个回答

tensorflow gradients好像不支持 int型的Tensor 的gradients 把w1的设置成float类型的例如tf.float32 gards就能算了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
TypeError: 'NoneType' object is not subscriptable
不知道咋了?求助[img=https://img-bbs.csdn.net/upload/201804/05/1522907557_991223.jpg][/img]
python+selenium 报错:TypeError: 'NoneType' object is not subscriptable
baidu1.pyrnrn#coding=utf-8rnfrom selenium import webdriverrnrndriver = webdriver.Firefox()rndriver.get("http://www.baidu.com")rnrnsize=driver.find_element_by_id('kw').sizernprint ("size")rnrntext=driver.find_element_by_id("cp").textrnprint ("text")rnrnattribute=driver.find_element_by_id("kw").get_attribute('type')rnprint ("attribute")rnrnresult=driver.find_element_by_id("kw").is_displayed()rnprint ("result")rnrndriver.quit()rnrnrnPython 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32rnType "copyright", "credits" or "license()" for more information.rn>>> rn RESTART: C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\baidu1.py rnTraceback (most recent call last):rn File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\baidu1.py", line 7, in rn size=driver.find_element_by_id('kw').sizern File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 519, in sizern new_size = "height": size["height"],rnTypeError: 'NoneType' object is not subscriptablern>>>
TypeError: 'NoneType' object is not iterable
部分代码如下,运行后总是提示 Traceback (most recent call last):n File "E:\project1\src\neirongxiangguanxing.py", line 156, in n setstatus = set(statuslist)nTypeError: 'NoneType' object is not iterable,什么原因?有没有大神指导下?非常感谢n```n for status in allstatus:n dictvalue = []n words = jieba.cut(status.gettext()[:-1])n for word in words:n if word not in stopwordslist:n dictvalue.append(word)n allstatusdict[status.getid()] = dictvaluenn allcomments = []n allcomments = readallcomments(inputfile)n for comment in allcomments:n statuslist = allstatusdict.get(comment.getid())n setstatus = set(statuslist)n dictcomment = []n words = jieba.cut(comment.gettext()[:-1])n for word in words:n if word not in stopwordslist:n dictcomment.append(word)n setcomment = set(dictcomment)n```nn
TypeError: 'NoneType' object is not subscriptable python3写的代码
报错在图片里面,不清楚具体怎么改。[img=https://img-bbs.csdn.net/upload/201710/09/1507512052_96666.png][/img]rn[code=python]rn# -*- coding: utf-8 -*-rn"""rnCreated on Sun Oct 8 20:20:44 2017rnrn@author: llrn"""rnrnimport numpy as nprnrndef findMax1(array):rn if len(array)<1:#len(array)得到列表长度rn return [-1,-1]rn index = 1rn unit = array[index]rn for j in range(1,len(array)):rn if array[j] > array[index+1] and array[j] > array[index-1]:#if的含多条件语句的写法rn unit = array[j]rn return [unit,j]#返回的是一个列表类型,最大值和它的坐标1rnrndef getMax1(matrix, column_Num):rn array = [col[column_Num] for col in matrix]#将找到的列循环遍历后放到列表中rn return findMax1(array)rn rndef getPeak(matrix, leftCol, rightCol):rn if rightCol <= leftCol:rn r = getMax1(matrix,leftCol)rn r.append(leftCol)rn mid = int((leftCol + rightCol) / 2)rn unit = getMax1(matrix, mid)#返回的变量名要和接收传参的名字一样rnrn rightElem = getMax1(matrix, mid+1)rn if leftCol == rightCol - 1:rn leftElem = unitrn if leftElem[0] > rightElem[0]:rn r = leftElemrn r.append(mid)rn else:rn r = rightElemrn r.append(mid+1)rn return rrnrn leftElem = getMax1(matrix, mid-1)rn if unit[0] >= leftElem[0] and unit[0] >= rightElem[0]:rn unit.append(mid)rn return unitrn if unit[0] < leftElem[0]:rn return getPeak(matrix,leftCol,mid-1)rn return getPeak(matrix,mid+1,rightCol)rnrnrnrnprint("please input row:")rnn = int(input())rnprint("please input column:")rnm = int(input())rnmatrix = np.random.randint(100,999,size=[n,m])rnprint(matrix)rnrnresult = getPeak(matrix,0,len(matrix[0])-1)rnrnprint(result)rnrn[/code]
hibernate 报错:argument type mismatch
请教下我的配置错在哪儿?该如何改正:rnrnException in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of org.wangchao.association.Class.studentsrn at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)rn at org.hibernate.tuple.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:330)rn at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:188)rn at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3232)rn at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:253)rn at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)rn at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)rn at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:502)rn at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:494)rn at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:134)rn at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)rn at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)rn at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)rn at org.hibernate.engine.Cascade.cascade(Cascade.java:248)rn at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:385)rn at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:242)rn at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)rn at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)rn at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)rn at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)rn at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)rn at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:530)rn at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)rn at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)rn at org.wangchao.association.Test.main(Test.java:78)rnCaused by: java.lang.IllegalArgumentException: argument type mismatchrn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)rn ... 30 morernrnrnrnrnrnrnrnrnrnrnrnrn
Function argument value,type,or count is invalid
现在做了个登陆界面:rnrnPUBLIC lnHandlernLOCAL a,brna=ALLTRIM(thisform.text1.Value)rnb=ALLTRIM(thisform.text2.Value)rnrnIF SQLEXEC(lnHandle,"select * from Login where lname=?a and lpwd=?b",'temp')>0rn IF USED('temp') AND RECCOUNT('temp')>0rn MESSAGEBOX('用户登录成功!')rn DO FORM ('form1.scx')rn thisform.Releasern ELSE rn MESSAGEBOX("用户名错误!",16,"ERROR")rn thisform.text1.SetFocusrn ENDIFrnENDIFrnrn数据库中有一张表,两个字段都为CHAR类型.rnrn现在运行程序出现Function argument value,type,or count is invalid,请教如何解决!
请教invalid type argument of `unary *'问题
int main (int argc, const char * argv[]) rn int a[4][4]=;rn for(int i=0;i<4;i++)rn rn for(int j=0;j<4;j++)rn rn a[i][j]=rand()%5;rn printf("a[%d][%d]=%d ",i,j,a[i][j]);rn rn rn printf("\n");rn rn int * p=a;rn printf("%d\n",*(*p+1));rn
error: invalid type argument of '->' (have 'Course')
typedef struct SCrn int Cno;rn int Grade;rn struct SC *next;rnSC;rnrntypedef struct Studentrn char Sno[8];rn char Sname[20];rn char Ssex[2];rn int Sage;rn char Sdept[2];rn struct Student *next;rn struct SC *scnext;rnStudent,*LinkList;rnrnrntypedef struct //课程的结构体rn int Cno; //课程编号rn char Cname[10]; //课程名rn double Ccredit; //课程的学分rnCourse;rnrntypedef struct SqList //课程的存储数据结构rnrn Course *elem; // 存储空间基址rn int length; // 当前长度rn int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)rnSqList;rnrnrnrnStatus Search_TotallCredit(LinkList L,SqList sql) //根据学号查询学生的总学分rn char sno[8]; //所查询的学号rn SC *sc;rn double totall=0; //总学分rn Student *s=L->next;rn printf("请输入你所要查询学生的学号:\n");rn scanf("%s",sno);rn while( strcmp(s->Sno,sno) )rn s=s->next;rn if(s==NULL)rn printf("您所输入的学号有误,不存在此学号的学生。\n");rn return ERROR;rn rn rn sc=s->scnext;rn while(sc!=NULL)rn totall+=sql.elem[sc->Cno]->Ccredit; // error: invalid type argument of '->' (have 'Course')rn sc=sc->next;rn rn printf("%s同学的总学分为%lf\n",s->Sname,totall);rn return OK;rnrnrnrn为什么总是报错 error: invalid type argument of '->' (have 'Course')
'NoneType' object has no attribute 'path'
用python3.5+selenium+firefox49.0 练习自动化测试rn以下是代码内容rnrn#coding=utf-8rnfrom selenium import webdriverrnrndriver = webdriver.Firefox()rndriver.get("http://www.baidu.com")rnrndriver.find_element_by_id("kw").send_keys("csdn")rndriver.find_element_by_id("su").click()rnrndriver.quit()rnrn执行成功了,没报错,但是报了这么个信息:rn'NoneType' object has no attribute 'path'rn查了好多资料啥的,都没个准确的方法,一开始我以为这个代码有问题,又写了别的用例,仍旧是能执行成功,但依然显示这个提示rn网上有些说是geckodriver没配置好,但是我是放到了python安装目录下的,python目录本身就在环境变量中,而且我用例也执行成功了rnrn哪位大神來指点一下?rn
'NoneType' object has no attribute '__getitem__'
按照《Ubuntu12.04.2 OpenStack Grizzly 安装(Bridge)》进行openstack安装,在配置keystone的时候,总是出现如下错误:rn> bash keystone.shrn 'NoneType' object has no attribute '__getitem__'rnrn不知道错在了哪里?rnrn《Ubuntu12.04.2 OpenStack Grizzly 安装(Bridge)》rnhttp://www.chenshake.com/ubuntu12-04-2-installed-openstack-grizzly-bridge-mode
求 an invalid argument was encountered 报错解决方案 急!!
小弟刚进入该论坛,分数不多,希望各位高手帮帮忙!rn在程序中出现了 an invalid argument was encountered 报错,请问下这个报错是系统的么?由于出现概率不高,所以根本没办法跟踪啊,解决这样的问题该怎么办!求高手指导。
python中绘制世界地图TypeError: argument of type 'Key' is not iterable。
按网上说的,都安装了。运行时一直报错:TypeError: argument of type 'Key' is not iterable。rn在网上下载的也是TypeError: argument of type 'Key' is not iterable。rn请大神分析下,谢谢!rnrn代码一:rn```rnimport pygal_maps_world.mapsrnrnwm = pygal_maps_world.maps.World()rnwm.title = 'North, Central, and South America'rnrnwm.add('North Amerca',['ca', 'mx', 'us'])rnwm.add('Central America',['bz', 'cr', 'gt', 'hn', 'ni', 'pa', 'sv'])rnwm.add('South America',['ar', 'bo', 'br', 'cl', 'co', 'ec', 'gf', 'gy', 'pe',rn 'py', 'sr', 'uy', 've'])rnrnwm.render_to_file('americas.svg')rn```rn代码二rnrn```rnimport pygalrnrnrnwm = pygal.maps.world.World()rnwm.title = 'Populations of Countries in North America'rnwm_key = 'ca':34126000, 'mx':113423000, 'us':309349000rnwm.add('North America',wm_key)rnrnrnwm.render_to_file('na_populations.svg')rn```
this declaration has no storage class or type specifier
刚接触CUDA,一个试手程序出了点问题,麻烦帮助。rn//host codern#include rn#include rn#define N 16rnvoid main()rnrn // allocate host memory rn int numBytes = N * sizeof(float) rn float* h_A = (float*) malloc(numBytes); rnrn // allocate device memory rn float* d_A = 0; rn cudaMalloc((void**)&d_A, numbytes); rnrn // copy data from host to device rn cudaMemcpy(d_A, h_A, numBytes, cudaMemcpyHostToDevice); rnrn // execute the kernel rn float blockSize = 4;rn float b = 1;rn increment_gpu<<< N/blockSize, blockSize>>>(d_A, b, N); rnrn // copy data from device back to host rn cudaMemcpy(h_A, d_A, numBytes, cudaMemcpyDeviceToHost); rnrn // free device memory rn cudaFree(d_A); rnrnrnrn//device codern#include rn_global_ void increment_gpu(float *a,float b,int n)rnrn int idx = blockIdx.x * blockDim.x + threadIdx.x;rn if(idx < n)rn a[idx] = a[idx] + b;rnrnrnbuild之后在_global_ void increment_gpu(float *a,float b,int n)处报错说this declaration has no storage class or type specifier。这是怎么回事?
invalid command line argument 'and'
版本12。0,打开服务器配置出现invalid command line argument 'and',怎么办?
python纸牌类TypeError: object of type 'FrenchDeck' has no len()
```rnimport collectionsrnCard=collections.namedtuple('Card',['rank','suit'])rnrnclass FrenchDeck:rn ranks = [str(n) for n in range(2,11)] + list('JKQA')rn suits = 'spades diamonds clubs hearts'.split( )rnrndef __init__(self):rn self._cards = [Card(rank,suit) for suit in self.suitsrn for rank in self.ranks]rndef __len__(self):rn return len(self._cards)rnrndef __getitem__(self,position):rn return self._cards[position]rnrn```rn为什么用len()显示TypeError: object of type 'FrenchDeck' has no len()
tensorflow 经典卷积神经网络的实现
tensorflow 经典卷积神经网络的实现
出现"invalid argument"错误:-(
我的一处程序是网络版的,是用SQL SERVER 2000 + DELPHI7的,数据库装在服务器上的,有几台电脑使用的时候是正常的,但有一台电脑上装上程序以后一运行就出现"invalid argument"错误.rn那台电脑一开始装的是WIN2000,后来我换成WINXP也不行.rnrn这是什么问题?是系统的问题还是程序的问题?该如何解决?谢谢.
Invalid procedure call or argument
維護公司原來的程序時,出現如下錯誤提示:rnrnLine: 38rnChar: 5rnError: Invalid procedure call or argumentrnCode: 800A0005rnSource: Microsoft VBScript runtime errorrnrn第38,39行代碼如下:rn iFreeSpace = FSO.GetDrive(sd).AvailableSpace/1024/1024/1024rn iTotalSpace = FSO.GetDrive(sd).TotalSize/1024/1024/1024 rnrn其中sd = "\\xx2hk-citrix1\C$"rnrn沒學過編程,請高手指點。謝謝!
invalid argument的问题
写了一个kernel函数,第一次调用是很正常,第二次调用时就出现了invalid argument的错误提示,rnrn我把kernel函数清空了,再调用还是出问题,貌似根本就没启动kernel函数,rnrn传的参数是device端的float指针,没进到函数里面,应该就不存在访问越界的问题吧,rnrn大家谁遇到过这个问题,请赐教~~
EVariantInvalidArgError Invalid argument
我在做一个三层时(使用TSocketConnection),正常查询没有问题。rn但我在TCPSERVER.execute中查询时,则提示如标题的错误。怎么解决?rn如果查询本地数据库,也没有问题rnrn简单测试代码如下:rnrn[code=Delphi(Pascal)]rn//以下如果直接调用,没有问题。rnprocedure TForm1.GetIDFromMAC(Mac: string);rnbeginrn tryrn//如果将下面的查询,改成本地数据,没有问题 CDSSearch是连接远程数据库。rn CDSSearch.Close; rn CDSSearch.CommandText:='Select * from HostList Where Trim(MAC) = "'+MAC+'"';rn CDSSearch.Open;rn if CDSSearch.IsEmpty thenrn ShowMessage('can''t find')rn else ShowMessage('find it');rn except on E:Exception dorn ShowMessage(e.Message);rnrn end;rnend;rnrnprocedure TForm1.TcpServerExecute(AContext: TIdContext);rnbeginrn GetIDFromMAC('00:10:23:14');rnend;rn[/code]rnrn感谢!
invalid argument to date encode
if (ComboBox4.Text <> '')and (ComboBox5.Text <> '')and(ComboBox6.Text <> '')and(ComboBox7.Text <> '')thenrn beginrn MyDate1 := EncodeDate(StrToInt(ComboBox4.Text), StrToInt(ComboBox5.Text), 1);rn if ComboBox6.Text <> '12' thenrn beginrn MyDate2 := EncodeDate(StrToInt(ComboBox6.Text), (StrToInt(ComboBox7.Text)+1), 1);rnrn endrn elsern beginrn MyDate2 := EncodeDate(StrToInt(ComboBox6.Text), StrToInt(ComboBox7.Text), 31);rn end;rn time1 := DateToStr(MyDate1);rn time2 := DateToStr(MyDate2);rn sql1 :=sql1+ ' and fydate>= '+''''+time1 +'''' + 'and fydate<= '+''''+time2+'''' ;rn // showmessage(sql1);rnrnrn end;rn不知道哪错了
invalid argument是什么问题
invalid argument是什么问题rnrnprocedure TPayApplyHeadForm.btnAddItemClick(Sender: TObject);rnbeginrn inherited;rnrn dgDetail.RowProps[dgDetail.Row].Checked := true;rnend;rnvarrn Item : TPay_Apply_Head ;rn iRow,i :Integer;rn Amount :Double;rnbeginrn Item := TPay_Apply_Head.Create;rn Item.Search_Flag := 6; //查询参数对应的物料rn msgbox('1111111111');rn tryrn if CommonSearchObj(TBizObject(Item), '') thenrnrn beginrn msgbox('qqqqqqq');rn iRow := dgDetail.GetFirstEmptyRow;rn if iRow = -1 thenrn beginrn msgbox('uuuuuuu');rn dgDetail.RowCount := dgDetail.RowCount + 1;rn iRow := dgDetail.RowCount - 1;rn end;rn if(Item.pay_type='质保金')thenrn beginrn msgbox('yyyyyy');rn for i := 1 to dgDetail.RowCount - 1 dorn beginrn msgbox('eeeeeeeee');rn if not dgDetail.RowProps[i].Checked thenrn beginrn msgbox('pppppp');rn Continue;rn end;rn if(dgDetail.CellByField2['pay_type',i]='月结款')or(dgDetail.CellByField2['pay_type',i]='预付款')rn or(dgDetail.CellByField2['pay_type',i]='退货款') thenrn Amount:=Amount+StrToFloatDef(dgDetail.CellByField2['Pay_Amount', i], 0);rn end;rn Amount:=-1*Amount*strtofloatdef(BedtASSURE_PERCENTAGE.text,0)/100;rn dgDetail.CellByField2['Pay_Amount',iRow] := Format('%0.2f',[Amount]);rn dgDetail.CellLocked[dgDetail.GetFieldIndex('Pay_Amount'),irow]:=true;rn end;rn if ( (Item.pay_type='订单补差价') or (Item.pay_type='无外箱') ) thenrn beginrn msgbox('nnnnnnnnn');rn dgDetail.CellLocked[dgDetail.GetFieldIndex('item_code'),iRow]:=False;rn dgDetail.Columns[dgDetail.GetFieldIndex('item_code')].ReadOnly:=False;rn end;rn rn dgDetail.CellByField2['source_id',iRow] := IntToStr(Item.Pay_Apply_Head_Id);rn dgDetail.CellByField2['bill_no',iRow] := Item.Bill_No;rn dgDetail.CellByField2['date_invbill',iRow] := Item.Date_Invbill;rn dgDetail.CellByField2['pay_type',iRow] := Item.pay_type;rn dgDetail.CellByField2['source_line_id',iRow] :=IntToStr(Item.pay_apply_line_id);rn //dgDetail.CellLocked[dgDetail.GetFieldIndex('Qty_Match'),iRow] :=True;rn //dgDetail.CellLocked[dgDetail.GetFieldIndex('Price_NoTax_Fact'),iRow] :=True;rn dgDetail.CellLocked[dgDetail.GetFieldIndex('pay_qty'),iRow]:=true;rn dgDetail.CellLocked[dgDetail.GetFieldIndex('Pay_Percent'),iRow]:=true;rn dgDetail.RowProps[iRow].Checked := True;rn dgDetail.CellByField2['Pay_Type_Id',iRow] := IntToStr(Item.Pay_Type_Id);rn end;rn finallyrn msgbox('mmmmmmmmmmm');rn Item.Free;rn end;rnrnend;
Invalid argument supplied 的错误
[code=PHP]rnchannel->item as $item )rnrn...rn[/code]rnrn在本地调试没事, 上传到服务器, 出现 PHP Warning: Invalid argument supplied for foreach() in ***.php on line 6rnrn请问foreach( $xml->channel->item as $item ) 这句错在哪里?
Invalid UTF-8 sequence in argument
页面向服务器发送一个ajax请求,服务端从数据库select数据然后把结果返回rn[code=php]rn$result['name'] = iconv('GBK','UTF-8',$result['name']);rnecho json_encode($result);rn[/code]rnrn代码再开发机和测试机都没问题,然后到线上就报这个错误:Invalid UTF-8 sequence in argument,是什么原因呢?
v4l Invalid argument
先贴上代码:rnopenvideo中:rn[code=C/C++][/code]int open_video( char *fileptr,fb_v41 *vd ,int dep,int pal,int width,int height)rnrn // 打开视频设备rn if ((vd->fd = open(fileptr, O_RDWR)) < 0) rn rn perror("v4l_open:");rn return ERR_VIDEO_OPEN;rn rn // 获取设备rn if (ioctl(vd->fd, VIDIOCGCAP, &(vd->capability)) < 0) rn rn perror("v4l_get_capability:");rn return ERR_VIDEO_GCAP;rn rn rnrn rn // 获取图象 rn if (ioctl(vd->fd, VIDIOCGPICT, &(vd->picture)) < 0) rn rn perror("v4l_get_picture");rn return ERR_VIDEO_GPIC;rn rn // 设置图象rn vd->picture.palette = pal; // 调色板rn vd->picture.depth = dep; // 像素深度rnrn vd->mmap.format =pal;rn if (ioctl(vd->fd, VIDIOCSPICT, &(vd->picture)) < 0) rn rn perror("v4l_set_palette");rn return ERR_VIDEO_SPIC;rn rn // rn vd->mmap.width = width; // width;rn vd->mmap.height = height; // height;rn vd->mmap.format = vd->picture.palette; rnrn vd->frame_current = 0;rn vd->frame_using[0] = 0;rn vd->frame_using[1] = 0;rn rn // 获取缓冲影射信息rn if (ioctl(vd->fd, VIDIOCGMBUF, &(vd->mbuf)) < 0) rn rn perror("v4l_get_mbuf");rn return -1;rn rn rn // 建立设备内存影射rn vd->map = mmap(0, vd->mbuf.size, PROT_READ|PROT_WRITE, MAP_SHARED, vd->fd, 0);rn if ( vd->map < 0) rn rn perror("v4l_mmap_init:mmap");rn return -1;rn rn printf("The video device was opened successfully.\n");rn // return get_first_frame(vd);rn return 0;rnrn主函数中这样调用:[code=C/C++][/code]rnret = open_video( V4L_FILE, &vd ,rn 16, // 像素深度rn VIDEO_PALETTE_RGB24, // 设置调包板rn 240,160 );rnrn运行结果如下:rnThe framebuffer device was opened successfully. rn480x272, 16bpp, xoffset=0 ,yoffset=0 rnThe framebuffer device was mapped to memory successfully. rnFrameBuffer OK! rnRGB_FB OK! rnThe video device was opened successfully. rnv4l_get_picture:: Invalid argument rn板子上出现了v4l_get_picture:: Invalid argument,无法运行下去。rnGoogle了很长时间,也没解决问题
an invalid argument was encountered
an invalid argument was encounteredrnrn是什么错误
pexpect调用ssh的报错:'NoneType' object has no attribute 'expect'
本人初学python,是菜鸟中的菜鸟。今天跑了一个脚本,调用pexpect连接ssh到远端服务器运行命令并返回结果。python版本是2.5.rn遇到报错,无法解决。望DX赐教。谢谢!rnrn错误信息(斜体字部分是脚本中定义的部分信息):rn[i]ERROR! 1rnSSH could not login. Here is what SSH said:[/i]rnPassword: rn'NoneType' object has no attribute 'expect'rnrn这个报错是说对象未定义类型?错误应该是发生在第一个if i==0处,但是child已经是由pexpect.spawn生成的对象了,为什么要报错说NoneType?rnrnrnrn完整脚本:(来源: http://www.oschina.net/question/12_7583 )rnrn#!/usr/bin/env pythonrnimport pexpectrnimport getpass, osrnrndef ssh_command(user, host, password, command):rn ssh_newkey="Are you sure you want to continue connecting"rn child = pexpect.spawn ('ssh -l %s %s %s'%(user, host, command))rn i=child.expect([pexpect.TIMEOUT, ssh_newkey, 'passowrd: '])rn if i==0:rn print 'ERROR! 1'rn print 'SSH could not login. Here is what SSH said:'rn print child.before, child.afterrn return Nonern if i==1:rn child.sendline('yes')rn child.expect('password: ')rn i=child.expect([pexpect.TIMEOUT, 'password: '])rn if i==0:rn print 'ERROR! 2'rn print 'SSH could not login. here is what SSH said:'rn print child.before, child.afterrn return Nonern child.sendline(password)rn return childrnrndef main():rn host = raw_input('Hostname: ')rn user = raw_input('User: ')rn password = getpass.getpass()rn command = raw_input('Enter the command: ')rn child = ssh_command(user, host, password, command)rn child.expect(pexpect.EOF)rn print child.beforernrnif __name__ == '__main__':rn try:rn main()rn except Exception, e:rn print str(e)rn# traceback.print_exc()rn os._exit(1)rnrn
为什么创建posix消息队列会有invalid argument
[code=C/C++]rn#include "unp.h"rnrnint main(int argc,char *argv[])rnrn mqd_t mqd;rn rn mqd=mq_open("mq",O_RDONLY|O_CREAT,FILE_MODE,NULL);rn if(mqd<0)rn rn perror("mq_open");rn exit(1);rn rn mq_close(mqd);rn return 0;rnrnrn[/code]rnrn后来改成/tmp/mq也不行,无效参数究竟是哪一个?rn还有是不是posix的信号灯用sem_wait和sem_post都要root的权限?但是创建不用?我sem_open创建后发现要sudo才能用sem_pos和sem_wait,我用的ubuntu
python代码报错(AttributeError: 'NoneType' object has no attribute 'run_line_magic')
import pandas as pdrnimport matplotlib.pyplot as plt,matplotlib.image as mpimgrnfrom sklearn.model_selection import train_test_splitrnfrom sklearn import svmrn[b]#~matplotlib inlinernfrom IPython import get_ipythonrnget_ipython().run_line_magic('matplotlib','iinline')[/b][color=#FF0000][/color]rnrnimport matlpotlibrnrnlabeled_images = pd.read_csv('D:/kaggle/train.csv')rnimages = labeled_images.iloc[0:5000,1:]rnlabels = labeled_images.iloc[0:5000,:1]rntrain_images,test_images,train_labels,test_labels = train_test_split(rn images,labels,train_size=0.8)rn rni=1rnimg = train_images.iloc[i].as_matrix()rnimg = img.reshape((28,28))rnplt.imshow(img,cmap='gray')rnplt.title(train_labels.iloc[i,0])rn主要是我想画图,如下[img=https://img-bbs.csdn.net/upload/201712/06/1512547153_833788.png][/img]rn[b]%matlpotlib inline会报错 invalid syntax,上网搜了下用ipython里的run_line_magic也不行[/b]所以想来问下大家rnrn小白的软件配置是:python3.6 和Geany
执行python代码报错(AttributeError: 'NoneType' object has no attribute 'magic')
执行python代码报错,在网上查了很久,都没有查到解决办法,请大神指导一下!谢谢!rnrn[root@master dataannl]# python -VrnPython 3.6.2rn[root@master dataannl]# rn[root@master dataannl]# rn[root@master dataannl]# cat example01.pyrn# -*- coding: utf-8 -*-rnrn# from pandas import Series,DataFramern# import pandas as pdrnrnfrom IPython import get_ipythonrnimport matplotlib.pyplot as pltrnget_ipython().magic(u'matplotlib inline')rnrnplt.ylabel('True Positive Rate') #坐标轴标签rnplt.ylim(0,1.05) #边界范围rnplt.xlim(0,1.05) #边界范围rnplt.legend(loc=4) #图例rnplt.show() #显示作图结果rnrn[root@master dataannl]# rn[root@master dataannl]# python example01.pyrnTraceback (most recent call last):rn File "example01.py", line 8, in rn get_ipython().magic(u'matplotlib inline')rnAttributeError: 'NoneType' object has no attribute 'magic'rn[root@master dataannl]#
java.lang.IllegalArgumentException: argument type mismatch
两个类:rnuserrnDate birthday;rnrnrnFormBeanrnString birthday;rnrnrn方法中:rnFormBean fb = new FormBean();rnfb.setBirthday("2012-11-12");rnrnUser user = new User();rnConvertUtils.register(new DateLocaleConverter(), Date.class);rnBeanUtils.copyProperties(user, ufb);rnrn最后一行执行出错,异常如题目。
qt 调用外部应用报错 QWSLock::down(): Invalid argument QWSLock::up(): Invalid argument
QT调用外部程序:rnrna -qws &rnrn调用brnQProcess *pro = new QProcess; rnpro->start("b"); rnrn报错rnQWSLock::down(): Invalid argument rnQWSLock::up(): Invalid argumentrnQWSLock::down(): Invalid argument rnQWSLock::up(): Invalid argumentrnQWSLock::down(): Invalid argument rnQWSLock::up(): Invalid argumentrnQWSLock::down(): Invalid argument rnQWSLock::up(): Invalid argumentrnrn这个需要怎么解决
argument type mismatch
exceptionrnrnjavax.servlet.ServletException: BeanUtils.populatern org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)rn org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)rn org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)rn org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:637)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn com.oa.filter.EncodingFilter.doFilter(EncodingFilter.java:23)rnrnroot causernrnjava.lang.IllegalArgumentException: argument type mismatchrn sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn java.lang.reflect.Method.invoke(Unknown Source)rn org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)rn org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)rn org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)rn org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)rn org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)rn org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)rn org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)rn org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)rn org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:637)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn com.oa.filter.EncodingFilter.doFilter(EncodingFilter.java:23)rnrnrnrn 加了:encType=multipart/form-datarnrn 页面数据绑定到form时数据类型也匹配rnrnrn 不是上面的两个问题,高手帮忙,请问是什么问题?rnrnrn
argument type mismatch异常
javax.servlet.ServletException: BeanUtils.populatern org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)rn org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)rn org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)rn org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)rn org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:709)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnroot cause rnrnjava.lang.IllegalArgumentException: argument type mismatchrnrn信息添加时异常 ,和文件上传没有关系 rnrn急~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!rn谢谢!!rnrn
分页报错(typeerror:page() missing 1 required positional argument:'number')
[code=python]rnfrom django.core.paginator import Paginator,PageNotAnInteger,EmptyPage;rn@login_requiredrndef guest_manage(request):rn username = request.session.get("user","");rn guest_list = Guest.objects.all();rn pagintor = Paginator(guest_list,2);rn page = request.GET.get("page");rn try:rn contacts = Paginator.page(page);rn except PageNotAnInteger:rn contacts = paginator.Page(1);rn except EmptyPage:rn contacts = paginator.page(paginator.num_pages);rn return render(request,"guest_manage.html","user":username,"guests":contacts);rn[/code]rn运行报这个错:typeerror:page() missing 1 required positional argument:'number'rn大神们帮忙看看呢
求解:python出现错误TypeError:TypeError: object of type 'int' has no len()怎么解决
[img=https://img-bbs.csdn.net/upload/201808/31/1535704037_757080.png][/img][img=https://img-bbs.csdn.net/upload/201808/31/1535704050_284239.png][/img]
glance image-list 'NoneType' object has no attribute '
我是安装了三个节点的openstack,控制节点,计算节点,存储节点rn没有安装Neutron。也就只有这一点和《openstack实战指南》不一样rn然后当我运行glance image-list后出现了这个错误rnroot@ubuntu-controller:/# glance image-listrn'NoneType' object has no attribute 'rfind'rn请问有没有人遇到过,帮帮我吧,都卡这里好几天了。。。。rnrnps;我还没有添加镜像到数据库中,添加镜像的时候也是报这个错误rn
keil报错:stm32f10x_type.h(23):error:#256:invalid invalid redeclaration of type
keil 4.00。rn在ST官网上下的固件包,用STM32F10x_StdPeriph_Lib_V3.4.0\Project\STM32F10x_StdPeriph_Template里的工程,编译正确。rnrn以下尝试了两种新建工程的方法,均失败:rn1。 将固件包里的例程和相应的CMSIS、StdPeriph_Driver拷到工程下,修改target options里的C/C++ include paths项为“..\;..\Src\App;..\Src\CMSIS;..\Src\Lib”,编译报错“D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(23): error: #256: invalid redeclaration of type name "s32" (declared at line 470 of "Src\App\stm32f10x.h")”等。rnrn2。 若在工程中添加的文件为固件包中的链接(而不是拷贝),完全按照template里的结构,并将include paths按照template进行修改,编译报错“Keil\ARM\INC\ST\STM32F10x\stm32f10x_conf.h(147): warning: #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 511 of "STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\stm32f10x.h")”等。rnrn推测KEIL安装目录下的为旧版lib,工程中使用的为新版,两者代码结构上有所不同。而编译器在编译了工程文件的同时,自动链接了KEIL安装目录下的文件,造成冲突。但是在选项中没找到配置是否链接KEIL安装目录下LIB的地方。不知推测是否正确,解决方法又如何。求指教。
Realm.getDefaultInstance()报错Class '类名' has been added.
我在原来的realm数据库上新增一个PageData2表然后配置了migrate,但是在调用getDefaultInstance方法的时候还是报错rn java.lang.RuntimeException: Unable to pause activity tv.mchang.iptv/tv.mchang.app.SplashActivity: io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the following errors:rn - Class 'PageDate2' has been added.rn at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3048)rn at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3003)rn at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2981)rn at android.app.ActivityThread.access$1000(ActivityThread.java:135)rn at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)rn at android.os.Handler.dispatchMessage(Handler.java:102)rn at android.os.Looper.loop(Looper.java:136)rn at android.app.ActivityThread.main(ActivityThread.java:5001)rn at java.lang.reflect.Method.invokeNative(Native Method)rn at java.lang.reflect.Method.invoke(Method.java:515)rn at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:812)rn at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)rn at dalvik.system.NativeStart.main(Native Method)rn Caused by: io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the following errors:rn - Class 'PageDate2' has been added.rn at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method)rn at io.realm.internal.OsSharedRealm.(OsSharedRealm.java:171)rn at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:241)rn at io.realm.BaseRealm.(BaseRealm.java:136)rn at io.realm.BaseRealm.(BaseRealm.java:105)rn at io.realm.Realm.(Realm.java:164)rn at io.realm.Realm.createInstance(Realm.java:435)rn at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:342)rn at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:282)rn at io.realm.Realm.getDefaultInstance(Realm.java:343)rn at tv.mchang.data.realm.statistics.StatisticsDataUtils.addPageData(StatisticsDataUtils.java:17)rn at tv.mchang.app.SplashActivity.saveStatisticsData(SplashActivity.java:216)rn at tv.mchang.app.SplashActivity.onPause(SplashActivity.java:211)rn at android.app.Activity.performPause(Activity.java:5351)rn at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1233)rn at com.odin.framework.hack.InstrumentationHook.callActivityOnPause(InstrumentationHook.java:352)rn at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3034)rn ... 12 morern 具体代码如下:rn 在Application初始化了Realm并设置了setDefaultConfiguration,原来schemaVersion为8,我改为9rn Realm.init(this);rn RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()rn .directory(realmDir)rn .name("DataCenter.realm")rn .schemaVersion(9)rn .migration(new McMigration())rn .build();rn Realm.setDefaultConfiguration(realmConfiguration);rn 然后在migrate新增rn if (oldVersion == 8) rn realmSchema.create("PageData2")rn .addField("pageName", String.class)rn .addField("stayTime", long.class)rn .addField("visitTimes", int.class);rn rn 原本每次新增的时候应该在结尾oldVersion++的,但是之前维护人员在版本为5之后就没有oldVersion++了,我应该怎么修复?具体情况如下:rn if (oldVersion == 5) rn realmSchema.get("OpusPublishInfo")rn .renameField("opusId", "publishId")rn .addField("mcId", long.class)rn .addField("songName", String.class)rn .addField("singer", String.class);rn oldVersion++;rn rn if (oldVersion == 6) rn realmSchema.get("VisitData")rn .removeField("visitTimes")rn .addField("visitTime", long.class);rn realmSchema.create("OrderEvent")rn .addField("videoId", String.class)rn .addField("videoType", String.class)rn .addField("eventTime", long.class);rn rn if (oldVersion == 7) rn realmSchema.remove("AccountInfo");rn realmSchema.remove("McUserInfo");rn rn if (oldVersion == 8) rn realmSchema.create("PageData2")rn .addField("pageName", String.class)rn .addField("stayTime", long.class)rn .addField("visitTimes", int.class);rn rn 然后新建类:rn public class PageDate2 extends RealmObject rnrn String pageName;rnrn long stayTime;rn int visitTimes;rnrn public PageDate2()rnrn rnrn public PageDate2(String pageName,long stayTime,int visitTimes)rn this.pageName = pageName;rn this.stayTime = stayTime;rn this.visitTimes = visitTimes;rn rn 最后调用:rn public static void addPageData(String pageName, long stayTimeMills) rn try (Realm realm = Realm.getDefaultInstance()) rn PageDate2 pageDate2 = new PageDate2(pageName,stayTimeMills,1);rn realm.executeTransactionAsync(new Realm.Transaction() rn @Overridern public void execute(Realm realm1) rn realm1.copyToRealmOrUpdate(pageDate2);rn rn );rn rn rn 报错!请问我在哪里出了问题?应该如何改正呢?求大佬指教!我上网查了很多但是还是找不到解决办法。
delphi中出现delphi中class EVariantInvalidArgError with message Invalid argument
delphi中串口编程在等待接收代码中出现class EVariantInvalidArgError with message Invalid argument的错误,请大师们帮帮忙!rnfunction TForm1.SendDataWait(RxLen: Integer; WaitTime: DWORD): Boolean;rnvar rn TT: DWORD;rn BufLength:integer;rn i:integer;rnbeginrn result := False;rn TT := GetTickCount;rn while (((GetTickCount - TT) < WaitTime) and (MSComm1.InBufferCount < RxLen)) dorn beginrn Application.ProcessMessages;rn Sleep(1000);rn end;rn BufLength:= MSComm1.InBufferCount;rn if BufLength =200 thenrn beginrn SetLength(RxBuf, BufLength);rn for i := 0 to 199 do RxBuf[i] := 0;rn RxBuf := MSComm1.Input; //这里出错,如果注释这一句就没错,但串口就接收不了数据了rn if BufLength>= RxLen thenrn beginrn result:= true;rn end;rn for i := 0 to (Length(RxBuf) - 1) dorn StatusBar1.Panels[1].Text := StatusBar1.Panels[1].Text + IntToHex(RxBuf[i], 2) + ' ';rn end;rnrnend;rn我这里RxBuf的定义为RxBuf:array of byte
相关热词 c# 标准差 计算 c#siki第五季 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池