但是,当我去运行模型fprop时,我会得到以下错误:
AttributeError: NoneType对象没有属性“sizeI”
我非常接近他们的榜样。我已经使用他们的ImageLoader训练了模型,现在我想在一个系统中利用结果。我尝试过使用model.get_outputs(ArrayIterator(myData)),但仍然存在问题。有什么想法吗?
xdev = np.zeros((3 * 224 * 224, batch_size), dtype=np.float32)
xbuf = np.zeros((3 * 224 * 224, batch_size), dtype=np.float32)
img = to_neon(new_img) # function to flatten image to (3 * 224 * 224, )
xbuf[:,0] = img[:, 0]
model = model.load_params("/path/to/params.p")
out = model.fprop(xdev)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-35-fc650f5dcbc4> in <module>()
----> 1 out = model.fprop(xdev)
/root/neon/neon/models/model.pyc in fprop(self, x, inference)
213 Tensor: the output of the final layer in the model
214 """
--> 215 return self.layers.fprop(x, inference)
216
217 def bprop(self, delta):
/root/neon/neon/layers/container.pyc in fprop(self, inputs, inference, beta)
248 x = l.fprop(x, inference, beta=beta)
249 else:
--> 250 x = l.fprop(x, inference)
251
252 if inference:
/root/neon/neon/layers/layer.pyc in fprop(self, inputs, inference, beta)
787 self.inputs = inputs
788 self.be.fprop_conv(self.nglayer, inputs, self.W, self.outputs, beta=beta,
--> 789 bsum=self.batch_sum)
790 return self.outputs
791
/root/neon/neon/backends/nervanagpu.pyc in fprop_conv(self, layer, I, F, O, X, bias, bsum, alpha, beta, relu, brelu, slope, repeat)
1936 repeat: used in benchmarking
1937 """
-> 1938 assert layer.sizeI == I.size
1939 assert layer.sizeF == F.size
1940 assert layer.sizeO == O.size
AttributeError: 'NoneType' object has no attribute 'sizeI'发布于 2016-08-27 22:46:26
在你的堆叠痕迹上倒转..。
此问题来自试图在layer对象为None时取消引用layer属性的尝试。
-> 1938 assert layer.sizeI == I.size
我会把它称为霓虹灯库(backends/nervanagpu.py)中的一个bug --它应该在1938年的那一行上面,类似于:
assert isinstance(layer, TheExpectedLayerClass)在layers/layer.py中,也可以在第788行之前添加类似的检查:
assert isinstance(self.nglayer, TheExpectedLayerClass)但是,在第三方库中经常碰到这样的But只是表明库的使用方式并没有达到预期的程度。错误只是掩盖了真正的原因,因为没有更早地进行适当的检查,在那里可能很清楚遗漏了什么。
因此,请查看文档/教程,可能您遗漏了一些init/setup步骤,或者其他一些参数,等等。或者,如果您更熟悉霓虹灯,请继续在堆栈跟踪上进行回退,直到找到丢失的内容。
https://stackoverflow.com/questions/39185835
复制相似问题