栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Exception has occurred: ValueErrorPosition or time array should be the same size as signal.

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Exception has occurred: ValueErrorPosition or time array should be the same size as signal.

1 问题

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设置都没用。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/740844.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号