ValueError: need at least one array to concatenate

引发原因:从空数组进行连接会引发此错误

报错提示为:

TFT_Dataset类报错相关部分源代码为:

for e in train[entity_column].unique():entity_group = data[data[entity_column]==e]data_time_steps = len(entity_group)if data_time_steps >= decoder_steps:x = entity_group[input_columns].values.astype(np.float32)inputs.append(np.stack([x[i:data_time_steps - (decoder_steps - 1) + i, :] for i in range(decoder_steps)], axis=1))  y = entity_group[[target_column]].values.astype(np.float32)outputs.append(np.stack([y[i:data_time_steps - (decoder_steps - 1) + i, :] for i in range(decoder_steps)], axis=1))e = entity_group[[entity_column]].values.astype(np.float32)entity.append(np.stack([e[i:data_time_steps - (decoder_steps - 1) + i, :] for i in range(decoder_steps)], axis=1))t = entity_group[[time_column]].values.astype(np.int64)time.append(np.stack([t[i:data_time_steps - (decoder_steps - 1) + i, :] for i in range(decoder_steps)], axis=1))self.inputs = np.concatenate(inputs, axis=0)self.outputs = np.concatenate(outputs, axis=0)[:, encoder_steps:, :]self.entity = np.concatenate(entity, axis=0)self.time = np.concatenate(time, axis=0)self.active_inputs = np.ones_like(outputs)

原因:当data为valid的时候,data_time_steps < decoder_steps,故返回的input为空

解决办法:添加当data_time_steps < decoder_steps情况时的处理

           else:return None

具体如下

for e in train[entity_column].unique():entity_group = data[data[entity_column]==e]data_time_steps = len(entity_group)if data_time_steps >= decoder_steps:x = entity_group[input_columns].values.astype(np.float32)inputs.append(np.stack([x[i:data_time_steps - (decoder_steps - 1) + i, :] for i in range(decoder_steps)], axis=1))  y = entity_group[[target_column]].values.astype(np.float32)outputs.append(np.stack([y[i:data_time_steps - (decoder_steps - 1) + i, :] for i in range(decoder_steps)], axis=1))e = entity_group[[entity_column]].values.astype(np.float32)entity.append(np.stack([e[i:data_time_steps - (decoder_steps - 1) + i, :] for i in range(decoder_steps)], axis=1))t = entity_group[[time_column]].values.astype(np.int64)time.append(np.stack([t[i:data_time_steps - (decoder_steps - 1) + i, :] for i in range(decoder_steps)], axis=1))else:return Noneself.inputs = np.concatenate(inputs, axis=0)self.outputs = np.concatenate(outputs, axis=0)[:, encoder_steps:, :]self.entity = np.concatenate(entity, axis=0)self.time = np.concatenate(time, axis=0)self.active_inputs = np.ones_like(outputs)

报错解决

解决ValueError: need at least one array to concatenate相关推荐

  1. MMDet: ValueError: need at least one array to concatenate

    文章首发及后续更新:https://mwhls.top/4051.html,无图/无目录/格式错误/更多相关请至首发页查看. 新的更新内容请到mwhls.top查看. 欢迎提出任何疑问及批评,非常感谢 ...

  2. ValueError: need at least one array to concatenate

    关键词 python 报错内容 ValueError: need at least one array to concatenate 原因 路径有误 可能入手的地方 1.检查下运行的py文件中写到的路 ...

  3. mmdetection ValueError: need at least one array to concatenate解决方案

    在mmdetection中有时候训练模型会出现ValueError: need at least one array to concatenate的错误,详情如下图所示. 很多人都说是mmdet/da ...

  4. 成功解决ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or

    成功解决ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or ...

  5. 成功解决ValueError: setting an array element with a sequence.

    成功解决ValueError: setting an array element with a sequence. 目录 解决问题 解决方法 解决问题 ValueError: setting an a ...

  6. 成功解决ValueError: Expected 2D array, got 1D array instead: Reshape your data either using array.reshap

    成功解决ValueError: Expected 2D array, got 1D array instead: Reshape your data either using array.reshap ...

  7. 成功解决ValueError: pos_label=1 is not a valid label: array([‘0‘, ‘1‘], dtype=‘<U1‘)

    成功解决ValueError: pos_label=1 is not a valid label: array(['0', '1'], dtype='<U1') 目录 解决问题 解决思路 解决方 ...

  8. 成功解决ValueError: array must not contain infs or NaNs(花了好几个小时解决了这个最离奇的bug)

    成功解决ValueError: array must not contain infs or NaNs(花了好几个小时解决了这个最离奇的bug) 目录 解决问题 解决思路 解决方法 问题背景

  9. 已解决ValueError: Expected 2D array, got 1D array instead

    已解决ValueError: Expected 2D array, got 1D array instead 文章目录 报错问题 解决方法 PS 报错问题 之前在工作中遇到过这个坑,记录一下问题以及解 ...

最新文章

  1. NLP(二十八)多标签文本分类
  2. JavaScript学习记录总结(四)——js函数的特殊性
  3. 不可逆的类初始化过程
  4. 公共无线网络多陷阱 ***称15分钟盗银行账号密码
  5. 火了这么久的 AI,现在怎么样了?
  6. [待解决]自定义头像时使用vue-cropper进行图片裁剪,得到的是base64格式的图片,如何对接file类型的api接口
  7. 被阿里P8面了两个小时,技术、业务有来有回......
  8. strlen函数_四种好用的PHP自定义加密函数(可逆/不可逆)
  9. 关于docker环境下mysql的使用相关
  10. if函数python_python入门(if函数)
  11. java删_JAVA删除文件夹
  12. MsSQL SQLServer 查询 表中字段的及类型是否为空
  13. Oracle表名、列名、约束名的长度限制
  14. 前端基础篇之 CSS 世界
  15. IEEE1588v2解析(7)gPTP协议和PTP的关系
  16. 第1章第14节:导出:如何将演示文稿保存为视频格式的文件 [PowerPoint精美幻灯片实战教程]
  17. 画圆的函数----(基于MATLAB)
  18. 渠道、数据、技术,谁才是网络信贷市场的决胜因素?
  19. 遥感应用发展观察(更新)
  20. 如何读论文[论文精读]

热门文章

  1. nordic 52832添加HID服务实现手机蓝牙自拍杆功能 附遇到的问题和解决方法
  2. 2618: [Cqoi2006]凸多边形
  3. 企业微信如何有效触达客户?
  4. golang 中regexp包用法
  5. Android service 启动篇之 startService
  6. 论文研究 | 基于机器视觉的钢材表面缺陷检测
  7. 金字塔思维---迎合他人的表达方法
  8. 国二C语言选择题知识点总结
  9. 新能源共享充电桩管理运营平台
  10. 计算机机房安全风险防控规范,中心机房安全风险分析一览表.doc