欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-05-27 10:32:41
...

报错:

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 时的输出形式,也输出一元。

 

解决: