当前位置: 代码迷 >> 综合 >> theano ValueError: ('setting an array element with a sequence.', 'Container name None')
  详细解决方案

theano ValueError: ('setting an array element with a sequence.', 'Container name None')

热度:59   发布时间:2023-12-15 17:05:04.0

产生问题的原因主要是shape无法对齐。解决方法就是找到赋值的那一句,顺藤摸瓜调整赋值两边的shape,使之一致。

对于我自己的代码来说,就是:

self.container.value = new_value 这一句两边的shape需要对齐。

报错:

Traceback (most recent call last):File "/home/usr1/abc.py", line 712, in <module>pred_times = lrc(input_clip=input_clip, th=threshold)File "/home/usr1/abc.py", line 674, in lrcpred_clip_times = process_clips(input_clip=input_clip, input_type='real_time')File "/home/usr1/abc.py", line 607, in process_clipsst_a_det.count(proFrame)File "/home/usr1/abc.py", line 341, in countself.do_local_count(classify, True)File "/home/usr1/abc.py", line 305, in do_local_counttest_set_x.set_value(framesArr, borrow=True)File "/home/user1/.local/lib/python3.6/site-packages/theano/compile/sharedvalue.py", line 146, in set_valueself.container.value = new_valueFile "/home/user1/.local/lib/python3.6/site-packages/theano/gof/link.py", line 479, in __set__self.storage[0] = self.type.filter(value, **kwargs)File "/home/user1/.local/lib/python3.6/site-packages/theano/tensor/type.py", line 150, in filterconverted_data = theano._asarray(data, self.dtype)File "/home/user1/.local/lib/python3.6/site-packages/theano/misc/safe_asarray.py", line 34, in _asarrayrval = np.asarray(a, dtype=dtype, order=order)File "/home/user1/.local/lib/python3.6/site-packages/numpy/core/numeric.py", line 538, in asarrayreturn array(a, dtype, copy=False, order=order)
ValueError: ('setting an array element with a sequence.', 'Container name "None"')

以下内容仅供我自己的项目参考,其他情况不具有普适性:

标准差为0,前后图像相同,然后输出为二元数组。标准差不为0,前后图像差别大的时候,输出为一元。不报错。

解决:

就是第一帧图像不要resize。后面的图像可以resize. 目标是保留信息,使标准差不再为0

或者改标准差为0 时的输出形式,也输出一元。

 

 

 

  相关解决方案