ValueError: attempt to get argmin of an empty sequence
[[{{node PyFunc}}]]
[[IteratorGetNext]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/feng/PycharmProjects/randla-net-tf2-main/main_S3DIS.py", line 302, in <module>
model.train(dataset)
File "/home/feng/PycharmProjects/randla-net-tf2-main/RandLANet.py", line 290, in train
print(e.op.name)
AttributeError: 'NoneType' object has no attribute 'name'
main_S3DIS.py复现出错
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
6条回答 默认 最新
阿里嘎多学长 2025-04-27 19:28关注阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程
错误分析
错误信息
ValueError: attempt to get argmin of an empty sequence表示尝试获取一个空序列的最小值,导致了错误。错误原因
可能的原因是
IteratorGet操作符返回的结果是一个空序列,导致了argmin操作的失败。解决方案
- 检查
IteratorGet操作符的结果是否为空,如果为空,需要检查数据是否正确。 - 如果
IteratorGet操作符的结果不为空,可以尝试使用np.where函数来获取非空的结果。
例如:
import numpy as np # ... result = IteratorGet(...) # 获取结果 if result.size > 0: min_idx = np.argmin(result) else: print("结果为空")代码示例
以下是一个简单的示例代码,演示如何使用
np.where函数来获取非空的结果:import numpy as np # ... result = IteratorGet(...) # 获取结果 min_idx = np.where(result != 0)[0] if min_idx.size > 0: min_idx = min_idx[0] else: print("结果为空")结论
错误
ValueError: attempt to get argmin of an empty sequence可能是由于IteratorGet操作符返回的结果为空导致的,可以尝试使用np.where函数来获取非空的结果。解决 无用评论 打赏 举报- 检查