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

产生问题的原因主要是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 lrc
    pred_clip_times = process_clips(input_clip=input_clip, input_type='real_time')
  File "/home/usr1/abc.py", line 607, in process_clips
    st_a_det.count(proFrame)
  File "/home/usr1/abc.py", line 341, in count
    self.do_local_count(classify, True)
  File "/home/usr1/abc.py", line 305, in do_local_count
    test_set_x.set_value(framesArr, borrow=True)
  File "/home/user1/.local/lib/python3.6/site-packages/theano/compile/sharedvalue.py", line 146, in set_value
    self.container.value = new_value
  File "/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 filter
    converted_data = theano._asarray(data, self.dtype)
  File "/home/user1/.local/lib/python3.6/site-packages/theano/misc/safe_asarray.py", line 34, in _asarray
    rval = np.asarray(a, dtype=dtype, order=order)
  File "/home/user1/.local/lib/python3.6/site-packages/numpy/core/numeric.py", line 538, in asarray
    return array(a, dtype, copy=False, order=order)
ValueError: ('setting an array element with a sequence.', 'Container name "None"')

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

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

解决:

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

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

发布了202 篇原创文章 · 获赞 80 · 访问量 30万+

猜你喜欢

转载自blog.csdn.net/qxqxqzzz/article/details/104837449