Python ';加里';对象没有属性';尺寸';使用nolearn-DBN分类器
我正在工作。Openface有e 我正在测试lfw分类未知。py的列车部件。 它有培训使用Python ';加里';对象没有属性';尺寸';使用nolearn-DBN分类器,python,python-2.7,numpy,python-nolearn,Python,Python 2.7,Numpy,Python Nolearn,我正在工作。Openface有e 我正在测试lfw分类未知。py的列车部件。 它有培训使用 nolearn-DBN classifier 我安装了nolearn版本0.5。 DBN分类器具有对/usr/local/lib/python2.7/dist-packages/gnumpy.py的函数调用和 我有个错误 File "/usr/local/lib/python2.7/dist-packages/gnumpy.py", line 738, in as_numpy_array if
nolearn-DBN classifier
我安装了nolearn版本0.5
。
DBN分类器
具有对/usr/local/lib/python2.7/dist-packages/gnumpy.py的函数调用
和
我有个错误
File "/usr/local/lib/python2.7/dist-packages/gnumpy.py", line 738, in as_numpy_array
if self.size==0: return numpy.zeros(self.shape, dtype)
AttributeError: 'garray' object has no attribute 'size'
我如何修复错误
所有的错误都是错误的
Traceback (most recent call last):
File "/usr/lib/python2.7/pdb.py", line 1314, in main
pdb._runscript(mainpyfile)
File "/usr/lib/python2.7/pdb.py", line 1233, in _runscript
self.run(statement)
File "/usr/lib/python2.7/bdb.py", line 400, in run
exec cmd in globals, locals
File "<string>", line 1, in <module>
File "evaluation/lfw-classification-unknown.py", line 519, in <module>
train(args)
File "evaluation/lfw-classification-unknown.py", line 130, in train
clf.fit(embeddings, labelsNum)
File "/usr/local/lib/python2.7/dist-packages/nolearn/dbn.py", line 409, in fit
self.use_dropout,
File "/usr/local/lib/python2.7/dist-packages/gdbn/dbn.py", line 202, in fineTune
err, outMB = step(inpMB, targMB, self.learnRates, self.momentum, self.L2Costs, useDropout)
File "/usr/local/lib/python2.7/dist-packages/gdbn/dbn.py", line 296, in stepNesterov
targetBatch = targetBatch if isinstance(targetBatch, gnp.garray) else gnp.garray(targetBatch)
File "/usr/local/lib/python2.7/dist-packages/gnumpy.py", line 735, in __new__
def __new__(cls, *args, **kwarg): return object.__new__(cls)
File "/usr/lib/python2.7/bdb.py", line 53, in trace_dispatch
return self.dispatch_return(frame, arg)
File "/usr/lib/python2.7/bdb.py", line 88, in dispatch_return
self.user_return(frame, arg)
File "/usr/lib/python2.7/pdb.py", line 190, in user_return
self.interaction(frame, None)
File "/usr/lib/python2.7/pdb.py", line 209, in interaction
self.print_stack_entry(self.stack[self.curindex])
File "/usr/lib/python2.7/pdb.py", line 900, in print_stack_entry
prompt_prefix)
File "/usr/lib/python2.7/bdb.py", line 381, in format_stack_entry
s = s + repr.repr(rv)
File "/usr/lib/python2.7/repr.py", line 24, in repr
return self.repr1(x, self.maxlevel)
File "/usr/lib/python2.7/repr.py", line 34, in repr1
s = __builtin__.repr(x)
File "/usr/local/lib/python2.7/dist-packages/gnumpy.py", line 1133, in __repr__
def __repr__(self): return self.as_numpy_array().__repr__().replace('array(', 'garray(').replace('\n', '\n ').replace(', dtype=float32', '').replace(', dtype=float64', '') # 64 happens for empty arrays
File "/usr/local/lib/python2.7/dist-packages/gnumpy.py", line 738, in as_numpy_array
if self.size==0: return numpy.zeros(self.shape, dtype)
AttributeError: 'garray' object has no attribute 'size'
> Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /usr/local/lib/python2.7/dist-packages/gnumpy.py(738)as_numpy_array()
-> if self.size==0: return numpy.zeros(self.shape, dtype)
回溯(最近一次呼叫最后一次):
文件“/usr/lib/python2.7/pdb.py”,第1314行,在main中
pdb.\u运行脚本(mainpyfile)
文件“/usr/lib/python2.7/pdb.py”,第1233行,在运行脚本中
self.run(语句)
文件“/usr/lib/python2.7/bdb.py”,第400行,正在运行
全局、局部中的exec cmd
文件“”,第1行,在
文件“evaluation/lfw classification unknown.py”,第519行,在
列车(args)
文件“evaluation/lfw classification unknown.py”,第130行,列车中
clf.fit(嵌入件、标签编号)
文件“/usr/local/lib/python2.7/dist-packages/nolearn/dbn.py”,第409行,适合
自我使用退出,
文件“/usr/local/lib/python2.7/dist packages/gdbn/dbn.py”,第202行,fineTune格式
err,outMB=step(inpMB,targetmb,self.learnRates,self.momentum,self.L2Costs,useDropout)
文件“/usr/local/lib/python2.7/dist packages/gdbn/dbn.py”,第296行,在stepNesterov中
targetBatch=targetBatch如果是instance(targetBatch,gnp.garay)或gnp.garay(targetBatch)
文件“/usr/local/lib/python2.7/dist-packages/gnumpy.py”,第735行,新__
def uuu new uuuu(cls,*args,**kwarg):返回对象。uuu new uuu(cls)
文件“/usr/lib/python2.7/bdb.py”,第53行,跟踪调度
返回自调度返回(帧,arg)
文件“/usr/lib/python2.7/bdb.py”,第88行,发送返回
self.user\u返回(帧,参数)
文件“/usr/lib/python2.7/pdb.py”,第190行,在用户返回中
自我互动(框架,无)
文件“/usr/lib/python2.7/pdb.py”,第209行,在交互中
self.print\u stack\u条目(self.stack[self.curindex])
文件“/usr/lib/python2.7/pdb.py”,第900行,在print\u stack\u条目中
提示(前缀)
文件“/usr/lib/python2.7/bdb.py”,第381行,格式为\u堆栈\u条目
s=s+repr.repr(rv)
repr中的文件“/usr/lib/python2.7/repr.py”,第24行
返回self.repr1(x,self.maxlevel)
repr1中的文件“/usr/lib/python2.7/repr.py”,第34行
s=uuu内置报告(x)
文件“/usr/local/lib/python2.7/dist-packages/gnumpy.py”,第1133行,在__
def(self):返回self.as_numpy_array()。uu repr_uu().replace('array('),'garray(')。replace('\n','\n')。replace(',dtype=float32','')。replace(',dtype=float64','')64发生在空数组中
文件“/usr/local/lib/python2.7/dist packages/gnumpy.py”,第738行,在as_numpy_数组中
如果self.size==0:返回numpy.zero(self.shape,dtype)
AttributeError:“garray”对象没有属性“size”
>未捕获异常。正在进入后期调试
运行“cont”或“step”将重新启动程序
>/usr/local/lib/python2.7/dist packages/gnumpy.py(738)as_numpy_array()
->如果self.size==0:返回numpy.zero(self.shape,dtype)
编辑:
如果未处于调试模式,则错误如下
Traceback (most recent call last):
File "evaluation/lfw-classification-unknown.py", line 519, in <module>
train(args)
File "evaluation/lfw-classification-unknown.py", line 130, in train
clf.fit(embeddings, labelsNum)
File "/usr/local/lib/python2.7/dist-packages/nolearn/dbn.py", line 407, in fit
self.use_dropout,
File "/usr/local/lib/python2.7/dist-packages/gdbn/dbn.py", line 202, in fineTune
err, outMB = step(inpMB, targMB, self.learnRates, self.momentum, self.L2Costs, useDropout)
File "/usr/local/lib/python2.7/dist-packages/gdbn/dbn.py", line 303, in stepNesterov
errSignals, outputActs, error = self.fpropBprop(inputBatch, targetBatch, useDropout)
File "/usr/local/lib/python2.7/dist-packages/gdbn/dbn.py", line 262, in fpropBprop
outputErrSignal = -self.outputActFunct.dErrordNetInput(targetBatch, self.state[-1], outputActs)
File "/usr/local/lib/python2.7/dist-packages/gdbn/activationFunctions.py", line 138, in dErrordNetInput
return acts - targets
File "/usr/local/lib/python2.7/dist-packages/gnumpy.py", line 965, in __sub__
else: return self + -as_garray(other) # if i need to broadcast, making use of the row add and col add methods is probably faster
File "/usr/local/lib/python2.7/dist-packages/gnumpy.py", line 926, in __add__
def __add__(self, other): return _check_number_types(self._broadcastable_op(as_garray_or_scalar(other), 'add'))
File "/usr/local/lib/python2.7/dist-packages/gnumpy.py", line 614, in _broadcastable_op
if reduce(operator.or_, ( other.shape[i] not in (1, self.shape[i]) for i in range(self.ndim)), False): raise ValueError('shape mismatch: objects cannot be broadcast to a single shape')
ValueError: shape mismatch: objects cannot be broadcast to a single shape
回溯(最近一次呼叫最后一次):
文件“evaluation/lfw classification unknown.py”,第519行,在
列车(args)
文件“evaluation/lfw classification unknown.py”,第130行,列车中
clf.fit(嵌入件、标签编号)
文件“/usr/local/lib/python2.7/dist-packages/nolearn/dbn.py”,第407行,适合
自我使用退出,
文件“/usr/local/lib/python2.7/dist packages/gdbn/dbn.py”,第202行,fineTune格式
err,outMB=step(inpMB,targetmb,self.learnRates,self.momentum,self.L2Costs,useDropout)
文件“/usr/local/lib/python2.7/dist packages/gdbn/dbn.py”,第303行,在stepNesterov中
errSignals,outputActs,error=self.fpropBprop(inputBatch,targetBatch,useDropout)
fprop中的文件“/usr/local/lib/python2.7/dist packages/gdbn/dbn.py”,第262行
OutputersSignal=-self.outputActFunct.dErrordNetInput(targetBatch,self.state[-1],outputActs)
文件“/usr/local/lib/python2.7/dist packages/gdbn/activationFunctions.py”,第138行,在DerrordNetput中
返回行动-目标
文件“/usr/local/lib/python2.7/dist-packages/gnumpy.py”,第965行,在__
else:返回self+-as_garray(other)#如果需要广播,使用row add和col add方法可能会更快
文件“/usr/local/lib/python2.7/dist-packages/gnumpy.py”,第926行,添加__
定义添加类型(self,other):返回检查类型(self.\u可广播类型(as\u garray\u或标量(other),'add'))
文件“/usr/local/lib/python2.7/dist packages/gnumpy.py”,第614行,可广播
如果范围(self.ndim)内的i的reduce(operator.or)(other.shape[i]不在(1,self.shape[i]),False):raise ValueError('形状不匹配:对象不能广播到单个形状')
ValueError:形状不匹配:无法将对象广播到单个形状
您没有发布任何实际的代码,因此不可能确切地知道您的问题所在
编辑
从堆栈跟踪中可以清楚地看出,您遇到的问题是由于pdb
试图在garray之后立即获取并打印garray
的值。调用了\uuuuu new\uuuuu
。这是在调用\uu init\uuuuuu
之前,因此.size
属性还不存在
在gnumpy.garray
代码中,似乎没有必要重新定义\uu new\uuuu
,因此您可以通过打开/usr/local/lib/python2.7/dist packages/gnumpy.py
然后注释掉第735行(即具有\uu new\uu\ucode>定义的行)来解决问题
更简单的是,如果只运行脚本而不使用pdb
(例如python lfw classification unknown.py
),会发生什么情况?这个特定错误似乎会消失。另一方面,您可能首先出于实际原因使用了调试器。您是否