报错信息:VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. Y_new = [np.squeeze(np.array(Y_new)).transpose()] # the aggregate output of 24 single outputs# 24个单独输出的聚合输出
解释原因:
警告信息是VisibleDeprecationWarning
,它与从不规则嵌套序列(即长度或形状不同的列表、元组或ndarray的列表或元组)创建NumPy数组有关。警告建议在创建ndarray时,如果你打算这样做,必须指定dtype=object
。
试图使用np.array(Y_new)
将Y_new
转换为NumPy数组。然而,由于Y_new
中的元素具有不同的长度或形状,这触发了这个警告。
为了解决这个警告并创建ndarray,在调用np.array()
时通过指定dtype
参数为'object'
来进行设置。
找到对应的行
Y_new = [np.squeeze(np.array(Y_new).transpose()]
改成
Y_new = [np.squeeze(np.array(Y_new, dtype=object)).transpose()]