勇博士科研能干明白么 2025-04-27 19:28 采纳率: 0%
浏览 13

main_S3DIS.py复现出错

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'

  • 写回答

6条回答 默认 最新

  • 阿里嘎多学长 2025-04-27 19:28
    关注

    阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程

    错误分析

    错误信息 ValueError: attempt to get argmin of an empty sequence 表示尝试获取一个空序列的最小值,导致了错误。

    错误原因

    可能的原因是 IteratorGet 操作符返回的结果是一个空序列,导致了 argmin 操作的失败。

    解决方案

    1. 检查 IteratorGet 操作符的结果是否为空,如果为空,需要检查数据是否正确。
    2. 如果 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 函数来获取非空的结果。

    评论

报告相同问题?

问题事件

  • 创建了问题 4月27日