Exception has occurred: ValueError
Position or time array should be the same size as signal.
2 问题Exception has occurred: ValueError
zero-size array to reduction operation minimum which has no identity
3 问题Found input variables with inconsistent numbers of samples
解决方案:y_true和y_predict行数不一致问题
reshape相应的行数,或者重新输入对应的样本和标签。这个问题的原因是样本数量和标签数量不对应。
总结,EMD(经验模态分解)中,数据问题主要是读取的数据维度问题,解决办法是将txt文档中的数字,通过删除其中的换行来保持所有的数据处于一行,然后才能处理,如果在使用算法进行特征识别时候,再通过reshape将其重新设定为样本和标签一一对应的数值关系。
删除txt文档中换行并保存新文件的代码:
def deleteAll_HuanHang1(Ori_file, Des_file):
with open(Des_file, 'w') as f:
with open(Ori_file, 'r') as fp:
for line in fp:
line = str(line).replace("n", " ")
f.write(line)
deleteAll_HuanHang1()
这样处理的时候就不会报上面的各种错误了。
后来查源文档发现,报错的原因是:
if S.shape != T.shape:
raise ValueError("Position or time array should be the same size as signal.")
但是就算是你用reshape设置都没用。



